[MZ-700] SDLEP-READER: What is it?

Post Reply
hlide
Posts: 146
Joined: Thu Jan 25, 2018 9:31 pm

[MZ-700] SDLEP-READER: What is it?

Post by hlide » Fri Feb 09, 2018 1:07 pm

The original link in French is here

Author: Daniel Coulom - Website: DCMOTO Emulator - Last updated on February 5, 2018

Here is a translation:

SDLEP-READER is an Arduino-based electronic editing. It allows TO and MO tape recorders to be replaced in playback, using "cassette image" files stored in a microSD card. The card can hold up to 128 files, selectable by 7 two-position switches. This system works for all cassettes, protected or not, with all computers in the Thomson 8-bit range. It only allows reading and not recording. Tests have also been successfully conducted with other computers using cassette players with analog audio output or TTL output, making SDLEP-READER a universal replacement tool for vintage computer cassette players.

Image

The problem of program cassettes

Cassette players have never been very reliable devices, and even with new hardware input/output errors were common. Today the mechanics are worn, the belts are distorted, the magnetic media have aged and it is even more difficult to read a cassette without error. The first generations of Thomson computers used this medium almost exclusively. The amount of programs and games on tape is impressive and a day will come when they will all be unreadable.

The replacement of a conventional tape recorder by an electronic system, without mechanical parts in motion and without magnetic support, brings absolute reliability and makes it possible to load the entire Thomson repository on cassette with great ease. It is a simple device, inexpensive, compact and very practical. In particular, copying a file on the SD card from a PC is of a disconcerting ease compared to the creation of an audio cassette with a tape recorder connected to the sound card.

Unfortunately, the loading time remains the same as that of a cassette, and this system does not allow to compete with the simulation of a floppy disk on SD card. Nevertheless, it is still of interest for cassette programs that do not exist in floppy disk format.

Description of the SDLEP-READER system

Image

The heart of the system is an Arduino Pro-Mini, based Atmega 328 or 168. It is added a module to access a microSD memory card in SPI mode. A block of 7 switches allows you to select a file from the card. This file is read and interpreted by the Arduino, which outputs to the Thomson computer the same signals as a Thomson cassette player. The MOTOR signal, sent by the computer to the Arduino, allows you to start the transmission or to stop it.

An electroluminescent diode gives indications on the operation of the system. It flashes at the rate of the data during the transmission, then by brief pulse every two seconds when the end of file is reached (end of cassette). When the system starts, if the file selected by the switches is not found on the card, this LED flashes very quickly to indicate the fault.

The mounting power can be done in many ways:
- by pin 5 of the optical pen connector, for computers that are equipped.
- via the 12V output of TO7 and TO7 / 70.
- by a 5V or 7V power supply at 12V.
- by a 9V battery.

The Arduino program

The program of the Arduino (sketch) uses its own functions to access the SD card as quickly as possible. They were partly inspired by the SimpleSDAudio library.
In addition, access to the card is performed by a command to read bytes directly, to avoid any undesirable delay.

The rest of the program is very simple and the comments explain the subtleties.
Download the program Arduino -> sd-lep_ino.zip

The structure of the cassette image files

Cassette images in .k7 format used by emulators may not be suitable for the tape recorder simulation because they do not contain the necessary information to reconstruct the signal. In particular, they do not know the delays between blocks, nor the frequencies used, nor the protection systems put in place by the software editors.

The .wav files reproduce the analog audio signal recorded on the tape, but not the digital signal generated by the tape recorder. This one is very close to the audio signal in the case of the LEP MO, on the other hand, it is totally different in the case of the LEP TO. A 44.1 kHz 8-bit monophonic .wav file is very big for the little information contained (49 bytes for 1 bit of information in the case of the TO), but in addition, it does not represent the signal sent by the tape recorder at the computer. It is not appropriate.

A new format, giving the required information in a condensed form, has been created. This is the .lep format whose specifications are listed below:

Code: Select all

=============================================================================== 
Cassette Format Thomson .lep 
=============================================================================== 

A .lep file is initially a cassette image Thomson, TO or MO.
It reproduces the output signal LEP TO and MO. 
By extension, it can also be used for all other formats of digital data recording on audio cassettes. 

-------------- 
Format TO 
-------------- 
The signal recorded on the tape is transformed into a sequence of bits according to  
the TO encoding system: 5 periods (4500 Hz) give a bit 0, 7 periods (6300 Hz) give
a bit 1. Each useful byte starts with a start bit of 0 and ends with two stop bits at 1.
The synchronization sequences and unsaved passages are replaced by 1-bit. 
A 44.1 kHz 8-bit mono .wav file is created. It is similar to the output of the TO tape recorder.
It contains 49 samples per bit, with a high level to encode bit 1 and a low level to encode bit 0. 

-------------------------- - 
MO format and other formats 
---------------------------- 
The mono 44.1 kHz 44-bit .wav file of the tape is shaped to contain rectangular slices of constant amplitude. 

--------------  
.lep file
-------------- 
Each byte of the .lep file contains the duration until the next value change of the signal.
This duration N is expressed in the unit given in parameter (50 μs), with the sign + for the positive state
and the sign - for the negative state. 
If the number N is greater than 127, there is a byte equal to the remainder of N / 127 
(or 1 if the remainder is zero) assigned the sign + or - according to the direction of the slot, 
followed by N / 127 bytes at zero.
Realization of the SDLEP-READER module

The SDLEP-READER module is made on a 5x3 cm strip circuit board. The Arduino is soldered to the wafer, but its connector is accessible for possible reprogramming in-situ. The module for the SD card is located at the top right on a female connector. The Arduino connector, on the top left, receives the connection cable with the computer. The connector in the middle on the right is used for the supply of 7V to 12V, in the case where the module is not supplied with 5V by the cable of connection.

Image

The construction is very simple and poses no particular problem. All components are standard and can easily be found on the internet for a nominal fee, without any shipping costs, from Shenzen's electronics vendors.

Image
Image

Start by cutting the strip circuit board to the right dimensions, so that it enters the housing. Cut the tracks according to the diagram, solder the straps, the connector of the SD card, the connector + 12V, the discrete components: diode, resistance and LED.

See for the rest of the building in the original link.

Making cables

See in the original link.

Use

The SDLEP-READER module is connected on the one hand to the tape recorder connector of the computer by a special cord, on the other hand to a power source. For computers with an external optical pen connector, this is the + 5V available at pin 5 of this connector. For the TO7 and TO7 / 70, this is the external 12V power socket located near the power switch. For other computers, you can use a 5V power supply (on the left connector), or a 7V to 12V power supply (on the right connector), or a 9V battery (on the right connector). Beware, only one power supply must be used. There is a big risk if the module is powered simultaneously by both connectors.

The 7 switches numbered from 1 to 7 allow choosing the file of the SD card to use.

Code: Select all

Determining the file name (extension .lep) according to the position of the 7 switches (128 possibilities). 

The file name is composed of seven digits 0 or 1 describing the position of the switches 1 to 7. 
Example: switches 2, 4, 6 to ON -> file 0101010.lep 
Example: switches 5 to ON -> file 0000100.lep 
Example: switches 1,2,3,5,7 to ON -> file 1110101.lep
The file selected by the switches must be present on the card. If it is not found, the activity LED flashes quickly when the power is turned on. Otherwise, it remains off until a program is loaded.

During loading, it flashes as data transfers. If the computer tries to read after the end of the file, the LED flashes every two seconds to signal the error "play after the end of the tape".

At any time, pressing the Arduino boot button rewinds the tape. To change the cassette, change the position of the switches and reset the Arduino.

The reading of the .lep file by the Arduino is very simplified. It does not consult the allocation table of the SD card during the loading of a cassette, to avoid delays incompatible with the principle of reading at constant speed. As a result, .lep files should not be fragmented. This is always the case when the card has just been formatted and no file has been deleted. On the other hand, if the card is almost full and file deletions have been made, there is a risk of fragmentation. In this case, it is advisable to make a backup copy of the files in a directory on the hard drive, format the SD card and then deliver the files.

For any further information

Please continue to the original link.

hlide
Posts: 146
Joined: Thu Jan 25, 2018 9:31 pm

Re: [MZ-700] SDLEP-READER: What is it?

Post by hlide » Fri Feb 09, 2018 1:33 pm

So I received some components (breadboard excluded):
IMG_20180202_201247.jpg
Starting soldering:
soldering.jpg
First try:
IMG_20180204_210605.jpg
---

Right now, I need to connect MOTOR and SENSE signals to GND so SDLEP-READER can transmit contents but that's not the way it should be done. So, I ordered an Arduino programming tool so can modify the firmware to handle the signal MOTOR the right way.

The delay granularity used by the Arduino firmware is 50 µS which excludes the ability to handle 3600 baud for instance. I hope the granularity can be finer to allow higher speed than 2400 baud.

hlide
Posts: 146
Joined: Thu Jan 25, 2018 9:31 pm

Re: [MZ-700] SDLEP-READER: What is it?

Post by hlide » Fri Feb 09, 2018 4:17 pm

Changes done:

In mzf2wav/src/methods:81

Code: Select all

  0x15, 0x01,       // D44B: 
I need to set 0x15 (3600 baud) to 0x1f (2400 baud) in the turboloader code.

I also tweaked speed 4 in mzf2wav/src/wav.h:22-25
original:

Code: Select all

#define TURBO_FAST_LONG_UP    3  // Fastest in turbo mode.
#define TURBO_FAST_LONG_DOWN  7
#define TURBO_FAST_SHORT_UP   3
#define TURBO_FAST_SHORT_DOWN 4
new:

Code: Select all

#define TURBO_FAST_LONG_UP    7  // Fastest in turbo mode.
#define TURBO_FAST_LONG_DOWN  11
#define TURBO_FAST_SHORT_UP   5
#define TURBO_FAST_SHORT_DOWN 6
I wasn't able to get working lower values to increase speed.

Results:

I was then able to load SEND-1 with SDLEP-READER:

mzf2wav -c SEND-1.mzf 0000000.wav
- conventional loading (1200 baud, like a real MZ tape): around 1min 26s

mzf2wav -s SEND-1.mzf 0000001.wav
- fast loading (1200 baud with half-shorter low pulses and shorter gaps before tapemarks): around 1min 16s

mzf2wav -w -t 2 SEND-1.mzf 0000011.wav
- turbo loading, speed 2 (2400 baud with shorter gaps before tapemarks): around 42s

mzf2wav -w -t 2 SEND-1.mzf 0000011.wav
- turbo loading, speed 4 (2400 baud with shorter low pulses and shorter gaps before tapemarks): around 40s

hlide
Posts: 146
Joined: Thu Jan 25, 2018 9:31 pm

Re: [MZ-700] SDLEP-READER: What is it?

Post by hlide » Sun Mar 04, 2018 10:47 pm

Short story:
My tweaked SDLEP-READER is now able to load up to 4 times faster.

Long story:
SDL-READER firmware has some short sightings regarding timings precision. It used a 50µs resolution for pulses. As a result, conversion from WAV to LEP was given 200µs for short pulses and 400µs for long pulses. While those "fast" pulses were working at normal speed and at turbo x2 speed after tweaking the turbo-loader program, turbo x3 was impossible to get.

I also noticed the code to wait for a pulse period was also too unprecise as it won't take into account the cycles spent on SD readings and interrupts.

So I decided to change the pulse resolution to 16 µs to have more precise periods and embed the WAV to LEP conversion into the mzf2wav tool and change the period polling into a precise one taking into account of the cycles of SD readings and interrupts.

As a result, I was able to get a turbo x3 mode. But I was also able to create a new turbo x4 mode.

hlide
Posts: 146
Joined: Thu Jan 25, 2018 9:31 pm

Re: [MZ-700] SDLEP-READER: What is it?

Post by hlide » Fri Mar 30, 2018 12:56 pm

Short story:
Firmware is rewritten from scratch to use SdFat library (FAT file can be fragmented now). Added Serial USB connection to select the name of the file to load because 7-interrupter DIP is kinda broken now.

Long story:
I hate the fact that the original firmware introduces too many limitations regarding the FAT access. I decided to use the full SdFat library but needed to overcome the bigger latency due to SD reading accesses. Now I issue the SD read accesses outside the critical read period and it works fine even in turbo X4 mode.

I also tried to add some GUI shields: screen and buttons/touchscreen. But it's harder than what I expected. They use so many pins that I have a hard job to find how to make tape signals and GUI pins to cohabitate.

Conclusion:

Using SdFat may lead to new possibilities:

- reading MZF files instead of LEP files and LEPifying them on the fly.
- recording MZF files?
- browsing the SD to select a file.
- using Serial USB to upload an MZF in the SD and making it load through "tape" playing to test it.

Other possibilities:

- to make the tape hardware work on MZ-80 K/A and MZ-800.
- to use the printer connector as an MZ terminal to drive the Arduino.
- to use the printer connector as a faster program transfer between MZ and Arduino.
- to use both READ and WRITE signals to allow faster program transfer between MZ and Arduino by letting the signal reader acknowledge the signal writer to fetch the next bit asynchronously.

And so on.

Post Reply