A project log for Cassette interface for FPGAs

Now your FPGA-based retro computer can have its own mass storage too - just like it did circa 1980!

zpekiczpekic 11/02/2020 at 06:500 Comments

Instruction to record data onto the tape:

  1. select baudrate and serial mode on Mercury baseboard switches 7 - 2, for example 001111XX will set 600bps, 8 bits, no parity, 2 stop bits (Note: 1200 bps will work with high quality recorder/tape and finely tuned volume and tone. 600 and 300 is much less demanding)
  2. use same setting on your Terminal software on the PC (for example TeraTerm)
  3. establish all wire connections (AUDIO_OUT > MIC, AUDIO IN < SPKR, PMOD USB to PC USB)
  4. rewind the tape to required position (and mark to catalog position)
  5. press RECORD
  6. send file (or simply type) in terminal console window - all bytes outgoing will be recorded onto the tape. In order to later see the recorded data, the simplest way is to send text. For example any HEX file or similar format can encode binary while still be human readable.
  7. press STOP when UART blinking stops (and mark to catalog position)

Principle of operation:

(refer to )

The recording is simple "binary frequency shift keying" with following parameters:

bpsmark ("1") frequency (Hz)space ("0") frequency (Hz)fmark

All of this is accomplished with simple multiplexer that transfers one of two incoming frequencies above to audio_left and audio_right pins (no stereo signal, but mono replicated on both channels if tape recorder uses only one):

-- output path
f_out <= freq_space when (serin = '0') else freq_mark;    -- always output to audio
audio_left  <= f_out; 
audio_right <= f_out; 

Given that frequencies are square waves which have infinite number of harmonics (sine waves), first of which is of the base frequency, and others rapidly attenuating odd multiples, and that these cannot be all stored on the tape, the signal that is actually stored is a distorted square/sine wave (see screenshot from oscilloscope). The D/A conversion happens on the path from FPGA output pin towards the tape. For other FPGA, a real D/A converter could be used which could easily generate very close approximation of a smooth sine wave of given mark/space frequency. But in the end it doesn't matter, as long as the receiver side can pick up the main harmonic component somehow from the analog signal recorded on the tape.

It is important to note that regardless of baudrate, each "1" will always result in 8 cycles and each "0" of 4 cycles within the bit time. This big 2/1 difference allows differentiation between 1 and 0 on the receiving side, but presents a problem - mark frequency of 19.2KHz is close to the upper reliable frequency reproduction limit of a cassette tape.