Microdrive data line format

Nagging hardware related question? Post here!
User avatar
gertk
Hardware Hero
Posts: 41
Joined: Mon Aug 19, 2013 10:00 pm

Re: Microdrive data line format

Post by gertk »

Dave wrote:Given the limitations of microdrives, if you're replacing the hardware that sits in the microdrive bays ANYWAY, why not use a floppy driver-based system? Given the extra simplicity and reliability, and roughly equal cost, it's an easier development path.

This is a cool project though.
You don not have to replace the internal drives, just use the MD port on the side of (each) QL
No further power supply is necessary. At minimum a reasonably fast microcontroller, a SD card and a voltage regulator is all it needs. It just needs some clever programming of the driver. The bandwidth of the MD port is quite good if only you could select distinctive sectors which is entirely feasible once you can send specific commands.
The driver should be able to read the directory and file attributes (especially file size) send the wanted filename and read for as many sectors as the file is long. The MD emulator should open the file on the sdcard and keep on sending sectors for as long as the QL keeps the emulated MD device selected. The whole FAT filesystem management is done on the emulator side.

Just wondering: And I will have to dive into the QL sources to see if maybe the QL can be tricked into 'keep on reading'. But maybe by manipulating the sector number on the fly it will load files larger than the maximum number of MD sectors.


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Microdrive data line format

Post by tofro »

Gert,

the problem with the existing driver is that basically everything is laid out for no more than 255 sectors. (The sector maps, the file and block # to be transferred to a write vectored routine, basically everything is byte-sized). I doubt this can be tricked to work with larger virtual tapes.

When you start to think about new drivers to be developed, you should first think about a clever way to use the limited hardware to send down information to the MD emulator.

What you have is the mechanism to select a drive # and the data1 and data2 lines (operated through one single transmit register) used to write bytes. From the top of my head, I can't see a simple way to "escape" from standard mode into some sort of "extended command mode" on the MD bus in order to be able to address specific sectors. There's still quite a bit of creative thinking required, I guess ;)

Regards,
Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
dilwyn
Mr QL
Posts: 2753
Joined: Wed Dec 01, 2010 10:39 pm

Re: Microdrive data line format

Post by dilwyn »

dex wrote:From this point of view, the ideal peripheral device was the ROMDisq (four expansion ROMs, e.g. Toolkit II, and flash-memory based storage). Pity, it was limited to 4 MB.
With larger space on flash, or with SD card, this will be unbeatable expansion.
I still have my RomDisq, although it's installed inside the MinisQL machine which doesn't get used very often. IIRC it has 8MB flash memory on it. I agree, if the RomDisq system could be redesigned to become an SD card interface, for example, (would probably depend on copyright issues as much as hardware/software redesign) it would be a fantastic little expansion for a QL.

Even an MDV-emulating SD card interface which either replaced the microdrives or plugged into the Microdrive expansion slot would be great, even better if as Rich suggested it could be persuaded to go beyond the limits of number of sectors etc set by the Microdrive driver.


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Microdrive data line format

Post by tofro »

Maybe trying to "write into the gap" could be a way to "escape"?

Something like that should never happen with standard microdrives.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Simon_Carr
Brittle Membrane
Posts: 118
Joined: Sun Sep 08, 2013 10:52 pm

Re: Microdrive data line format

Post by Simon_Carr »

This looks like a great project, very much on the lines of Dan Antohi's excellent IF1bis for the Spectrum. I know that his whole project is open-source, and being a complete QL novice I dont know whether any of his design and code is of value, but I really like the idea of the SD card becoming a virtual microdrive, accessed by the same commands...

If this gets to final development,I will definitely be buying one!


Unpacking a JS-ROM QL, with a QL-SD and SuperQBoard, and busily refelting millions of microdrives
User avatar
gertk
Hardware Hero
Posts: 41
Joined: Mon Aug 19, 2013 10:00 pm

Re: Microdrive data line format

Post by gertk »

tofro wrote:Gert,

the problem with the existing driver is that basically everything is laid out for no more than 255 sectors. (The sector maps, the file and block # to be transferred to a write vectored routine, basically everything is byte-sized). I doubt this can be tricked to work with larger virtual tapes.
I was thinking something along the line of: QL sends command to start the tape and waits for a specific sector to come by, then starts loading and stops depending on a specific sector number to come by. What if the same sector number comes by multiple times ? Does it simply shift the data into memory and tries to continue to read the next sector ?
When you start to think about new drivers to be developed, you should first think about a clever way to use the limited hardware to send down information to the MD emulator.

What you have is the mechanism to select a drive # and the data1 and data2 lines (operated through one single transmit register) used to write bytes. From the top of my head, I can't see a simple way to "escape" from standard mode into some sort of "extended command mode" on the MD bus in order to be able to address specific sectors. There's still quite a bit of creative thinking required, I guess ;)
The drive select mechanism is the best way to initiate extra commands to the MD emulator. By using MD8 as a 'command channel' it is quite easy to do specific things. You still need to load a driver for that but that can be done over the 'standard' MD system.

The QL simply selects device 8, activates the write line, sends a command, switch back to reading mode and waits for an answer.


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Microdrive data line format

Post by tofro »

gertk wrote: I was thinking something along the line of: QL sends command to start the tape and waits for a specific sector to come by, then starts loading and stops depending on a specific sector number to come by. What if the same sector number comes by multiple times ? Does it simply shift the data into memory and tries to continue to read the next sector ?
The algorithm used to read MD files differs between system calls:

When reading sequentially, the O/S just looks into the map, determines the next sector # to be read and reads that.

When loading fixed-size files, the O/S uses "scattered read", i.e., determines what sectors need to be read in, and, regardless of their sequence and places whatever comes by and belongs into the file into the correct place in memory where it belongs (according to the microdrive map). (That is why "FS.LOAD" is much faster than reading the bytes in sequentially)

When the same sector comes by twice, this is a perfectly normal case for the standard MD drivers - It will just assume the tape looped around and ignore the sector completely. The driver can't know whether the rest of the O/S has done something "more important" in the meantime.
The drive select mechanism is the best way to initiate extra commands to the MD emulator. By using MD8 as a 'command channel' it is quite easy to do specific things. You still need to load a driver for that but that can be done over the 'standard' MD system.

The QL simply selects device 8, activates the write line, sends a command, switch back to reading mode and waits for an answer.
Right - Simple enough. I wasn't realizing that you can mis-use higher MD drive numbers for a control session.

Again: Very interesting project! Keep on with the good work!

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
gertk
Hardware Hero
Posts: 41
Joined: Mon Aug 19, 2013 10:00 pm

Re: Microdrive data line format

Post by gertk »

From breadboard to prototype..
Prototype connected to MD port
Prototype connected to MD port
proto MD emulator
proto MD emulator
simple connections
simple connections
I used a Recom 7805 replacement R-785.0-1.0 (switching type regulator) to reduce the voltage from the QL (9 Volts) to 5 Volts before feeding it into the mbed. Theoretically it would be possible to attach the raw QL voltage directly to the mbed (allowable input is 5 to 9 Volts). The SD card adapter is used as a microSD connector. You can solder on those adapters quite easily and they are free with each microSD card...


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Microdrive data line format

Post by RWAP »

tofro wrote:
Right - Simple enough. I wasn't realizing that you can mis-use higher MD drive numbers for a control session.

Again: Very interesting project! Keep on with the good work!

Tobias
Yes - this could be a possibility, as not many people would be using mdv8_ for example, but there are a couple of issues here, not least of which is the ROM bug in some QLs which means accessing mdv8_ could leave mdv2_ inoperable (from memory).

However, I have seen Spectrum setups with several microdrive units attached.

You also need to be able to find a way of emulating more than one virtual microdrive at a time.

My best option would be to ignore the ROM bug (people would need to change their ROM if this was an issue), and leave mdv8_ as a control port.

You can then write to a fiename, say mdv8_controlO to say which microdrive image should be allocated to which slots, and maybe use reads on that port from OPEN_IN #3,mdv8_controlI, to find out information, such as a list of what virtual microdrives are attached to which microdrive numbers.

I can't imagine there are many systems with 8 attached microdrives - and in any case, they may wish to replace one or two with the new emulator.

This approach would work fairly well with the Spectrum also!


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Microdrive data line format

Post by tofro »

Well, actually, I would be fine with Gert's emulator only emulating mdv1_ and, probably, mdv2_ with two 100kB images.

That would be enough to properly boot from and load a driver that would make available the complete SD card for access through the QL by using the hardware that would normally be needed for mdv8_ (that would probably implement a device called sd1_ or whatever.) After the "new driver" would be booted, there wouldn't be any need to further access mdv1_ and mdv2_

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
Post Reply