Real Floppy Drive

Lukage
Posts: 49
Joined: Wed Aug 05, 2020 7:34 pm
Been thanked: 55 times

Real Floppy Drive

Unread post by Lukage »

EDIT 20.12.2020: Some time passed since this first post, and there is actually some progress on Minimig external floppy drive. Current progress:
- current version does not need specialized interface, just level conversion 3V3 -> 5V on GPIO
- floppy control is done
- floppy data read is done
- floppy data write with write precompensation is done with bugs
TODO:
- stabilize write
- catch bugs in DMA transfer code
- better integration with MiSTer
- floppy interface schematic & board

Original post:

I've decided to wire an actual floppy drive to MiSTer. At first, I thought it should be easy, but it turned out that doing that flawlessly is hard. Because of what I know, I chose Amiga core to tinker with, and I am using a ordinary PC floppy drive. This has some drawbacks from the beginning, because the ordinary PC floppy is not compatible, and itself needs some hacking or proper Amiga signal emulation.

If I was to stay compatible with MiSTer addons and boards, I was stuck with USB3 connector for user port, which is unused in Amiga core. This actual version uses only 4 wires from that user port, and there is a high-speed SPI-like interface between MiSTer and Xilinx CPLD I had laying around. I've created quick PCB to wire that together, and to form some sort of "breadboard".

Bidirectional control signals between floppy and Amiga are not high-speed at all, but the actual problem are signals for disk reading and writing. These are analogue-ish signals, and they need to be handled with precise timing to achieve good reading and writing. And this is exactly the problem with current SPI-like interface - the DPLL needed to properly read the floppy needs to have actual phases read as precise as possible, to be able to lock to signals from older floppy disks, or using older drives with not so much disk rotation precision. Current setup depends on SPI-like interface timing, and the phase of the signal is modified via data transfer. This poses problem with data decoding, albeit I was able to read some sectors, and was able to detect MFM preamble on real Amiga-written disks.

Right now, I am deciding between two approaches to a solid, proper, and maybe better reading and writing than original hardware - older floppy disks can be unreadable by Paula, but perfectly readable using better algorithms.

First one is just modify this design for larger CPLD, add oscillator to it, timestamp read pulses for further processing inside MiSTer FPGA, and do the same with write pulses - send them with timestamp, and write them from some FIFO with exact timing. This is a way to have interface independent on core and system, and add system-dependent processing inside each core.

Second one is to use a ARM microcontroller to do all the heavy lifting with proper data synchronization, which would enable the use of a low-speed serial protocol to communicate with MiSTer, and possibly to use better algorithms to try to read as best as possible. But this would need to have different disk formats inside ARM itself, and MiSTer would need to select this format. Also, there is a variant of this using MiSTer HPS, but so far I did not figured out a way to wire the floppy to it. I can of course sacrifice some peripheral on MiSTer to wire all signals from the floppy via level converter into FPGA (VGA port comes into mind, as I am not using it at all, I am using HDMI, and for VGA use there is HDMI-VGA conversion), and do all of this processing inside FPGA or on HPS, but my aim was to stay compatible.

I don't know, I though this will be a fun weekend project, but it turns out that doing this in a proper and compatible way is not so easy. What do you think ? Any ideas ? Did someone already did this ?
Attachments
floppyint.jpg
floppyint.jpg (381.29 KiB) Viewed 27938 times
User avatar
toastboy
Posts: 69
Joined: Wed Sep 09, 2020 9:20 pm
Has thanked: 13 times
Been thanked: 20 times

Re: Real floppy drive

Unread post by toastboy »

Wow - nice work in getting it this far!
A floppy interface for the Mister would be a fantastic improvement to many cores, especially the amiga.

As far as I've known - the only other system capable of reading amiga floppies was the old 2-drive-trick on the PC, which was read-only, fiddly to set up and pretty slow/unreliable, no disrespect to the people who got it working of course.

Is it not possible to use the arduino header to control the drive directly from mister? It provides 16 GPIO pins.

Amiga internal floppy drive has 15 active pins, 16 GND pins and 3 N/C on its 34-pin connector.
https://4.bp.blogspot.com/-UkaRAHw6gms/ ... nector.png

The arduino header's ADC pins, or the DE10's ADC pins might also be useful for those "analogue-ish" signals, albeit they seem to be input-only, so you couldn't use them to write.

I'm also aware that you must have considered this, so am expecting really to just find out why I'm wrong :-).
User avatar
kathleen
Top Contributor
Posts: 421
Joined: Fri Jun 26, 2020 4:23 am
Location: Belgium
Has thanked: 243 times
Been thanked: 138 times

Re: Real floppy drive

Unread post by kathleen »

@Lukage, first of all, thank you for your hard work.

I agree with you @toastboy, this would be fantastic to be able to read and even write on real floppy disks via the Minimig core of course but not only, it would also be a fantastic add-on for the AO486.

For information on PC there is an interface called ADF-Copy which works really well to read/write amiga disks, this interface connected in USB to the PC needs a simple PC floppy drive. I own one and it works quite well

https://nickslabor.niteto.de/projekte/adf-copy-english/

かすりん

high-5
Posts: 8
Joined: Mon May 25, 2020 6:31 pm
Has thanked: 2 times

Re: Real floppy drive

Unread post by high-5 »

Sounds like rocket science for me - great project!

When it comes to read Amiga discs with PC drive I have used a commercial product called catweasel on PC:http://wiki.icomp.de/wiki/Catweasel - works great.
You can find some insides how it works and there is some OSS to read/write different file formats with it under that link - maybe this could be helpful.
Lukage
Posts: 49
Joined: Wed Aug 05, 2020 7:34 pm
Been thanked: 55 times

Re: Real floppy drive

Unread post by Lukage »

The page on niteto.de shows exactly where is the problem with connection to MiSTer. You can see there is a graph with raw timings between read pulses in microseconds - there should be lines at 4, 6 and 8 microseconds, but you can see that it heavily varies with quality of the drive, and of course quality of the disks. This needs either direct connection to FPGA, or some intelligent device on floppy side, to be able to read and write properly, correctly, and possibly in a better way than original hardware.

As I said, I know how to read the disks, this is more like about some discussion about how to connect it to MiSTer in compatible way, compatible meaning with current IO board and expansion portfolio. If I look at my MiSTer with IO board v 6.1, only thing which is free to use is user port. In digital I/O board case, the whole expansion connector which is normally occupied with analog IO board 6.1 is "free" to use, "free" meaning, that it can be reprogrammed, but it will invalidate MiSTer template, and all cores would have need recompiling.

I am still thinking about user port, it does have 6 or 7 lines for I/O available, which should be enough, if I divide the problem. If I still use SPI-like interface for slow I/O for motor and head control and getting status updates, I still should have enough lines available to feed read and write pulses directly to/from FPGA. That way, MiSTer template would not need to be modified, and everything system-specific should be in each core source code.

I will create a new "breadboard" this week, any thoughts and ideas are welcomed !
RetroP
Posts: 29
Joined: Sun May 24, 2020 8:55 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Real floppy drive

Unread post by RetroP »

I'm pretty sure a clever chap could interface a Greaseweasle with Mister:
https://github.com/keirf/Greaseweazle/w ... zle-Models
Chol
Posts: 19
Joined: Sun May 24, 2020 8:24 pm
Has thanked: 2 times
Been thanked: 5 times

Re: Real floppy drive

Unread post by Chol »

Can't you use https://github.com/keirf/Greaseweazle for this, so the hardware-side floppy drive to USB interfacing is already solved and you "only" need to implement the software part?
Lukage
Posts: 49
Joined: Wed Aug 05, 2020 7:34 pm
Been thanked: 55 times

Re: Real floppy drive

Unread post by Lukage »

Today I checked, that raw floppy read and write signals can get through user port flawlessly, so it is possible to use the drive directly by FPGA. I will create another board, exploiting all user I/O available on USB3 connector. I am still thinking about dumb interface, doing everything core-wise on FPGA.

Using Greaseweazle, as it is a USB peripheral, would yield only possibility for floppy emulation, not full physical integration. It would not meet VIA/Paula timing needs, and modified/copyprotected/altered disks would be unreadable and not working.
Lukage
Posts: 49
Joined: Wed Aug 05, 2020 7:34 pm
Been thanked: 55 times

Re: Real floppy drive

Unread post by Lukage »

Update: Today I recreated what I think is the original receiving circuitry in Paula. It is working, I am posting output from inside FPGA, where you can clearly see training sequence (should be AAAA AAAA at the beginning, but it is actually 2AAA AAAA because the disk was written on real old Amiga with bug), MFM syncword (4489 4489), info part of sector header and unused part (those AAAAs at the end). With direct connection of disk read pin from floppy into FPGA the DPLL is no longer unlocking, and I can see clearly different sectors with correct headers. The dskrd_edge signal is negative edge detector output which shows raw floppy drive data. The whole thing runs on original Amiga PAL system frequency, how it is intended.

There are disputes about how exactly was DPLL in Paula working, so please, if anyone have some info about this, it is much appreciated (especially different phase / frequency correction steps for different input window detector). I would like to have the circuitry as much alike the original Amiga, because my goal is to be able to read all disks which are readable with real Amiga.

EDIT: add better picture showing DPLL internals.
Attachments
dpll.png
dpll.png (117.45 KiB) Viewed 27501 times
User avatar
toastboy
Posts: 69
Joined: Wed Sep 09, 2020 9:20 pm
Has thanked: 13 times
Been thanked: 20 times

Re: Real floppy drive

Unread post by toastboy »

Wow, just wow. That is incredible work.
Hooking the drive up to the FPGA paula is the ideal situation, I was more expecting a linux-land device that could r/w tracks, so this is much better.
Whatever board comes out of this, I will be buying/building one.

Don't know if you've seen this, but commodore filed a patent for a DPLL with a long and detailed description.
https://patents.justia.com/patent/4780844

I found the patent number in the comments on this guy's blog - perhaps he can add a bit of insight too.
https://www.techtravels.org/2008/09/how ... /#comments

BTW My IO board arrived today, and I see why the arduino port is not at all possible, it's partly used and completely obscured.
User avatar
Newsdee
Top Contributor
Posts: 873
Joined: Mon May 25, 2020 1:07 am
Has thanked: 104 times
Been thanked: 239 times

Re: Real floppy drive

Unread post by Newsdee »

This is a really interesting project... especially if you can get it running via de existing user IO pins (so it's standard).

Could that approach eventually benefit other computer cores... like say reading Mac floppies?
I suppose a similar approach could be done for 5" drives for older computers (not requesting it, just saying it would lay the foundation for it).
User avatar
ericgus09
Posts: 217
Joined: Mon May 25, 2020 2:47 am
Has thanked: 12 times
Been thanked: 32 times

Re: Real floppy drive

Unread post by ericgus09 »

Lukage wrote: Mon Nov 16, 2020 6:05 pm The whole thing runs on original Amiga PAL system frequency, how it is intended.
What about NTSC system frequency how its intended when in NTSC mode .. ?
User avatar
Reed_Solomon
Posts: 65
Joined: Sun May 24, 2020 7:37 pm
Has thanked: 40 times
Been thanked: 8 times

Re: Real floppy drive

Unread post by Reed_Solomon »

I'm intrigued and wish you the best of luck in your attempts on the Amiga floppy connector.

I've been wondering if USB-Floppy could work for ao486 but this would be another solution if you succeed with Amiga.
User avatar
Caldor
Top Contributor
Posts: 930
Joined: Sat Jul 25, 2020 11:20 am
Has thanked: 112 times
Been thanked: 111 times

Re: Real floppy drive

Unread post by Caldor »

Impressive :) When it comes to the Minimig and AO486 core... but especially the Minimig core, I have been hoping to see floppy support. Also because it might also work with Gotek drives then.

I have some input on this as well. Pretty sure I have seen a project somewhere on how to make a PC floppy drive compatible with an Amiga. I am guessing that might help here? Then there are the Gotek drives. There are several Gotek types now, where people have made branches of Gotek drives. The one who made an open source Gotek bios also made Catweasel, or Greaseweasel... maybe both. But what I like about the Gotek drives is that they support copy protected disk images, which the Minimig core does not currently do.

I see that Catweasel and Greaseweasel have already been mentioned. But other options are the Kyroflux and SuperCard Pro. But they are not open source, and they are mainly used to create images of disks, not work as a direct interface.
retrorepair
Posts: 257
Joined: Sun May 24, 2020 9:06 pm
Has thanked: 64 times
Been thanked: 13 times

Re: Real floppy drive

Unread post by retrorepair »

Amazing work, this also explains some of the issues I had with motor control so good to know.

Will this be open source or will you be selling hardware? Because I definitely need this in my life :)

I've hundreds of old disks with my own Octamed mods and pictures I drew when I was a teenager, would be awesome to load them up (and then back them up) on MiSTer!
Lukage
Posts: 49
Joined: Wed Aug 05, 2020 7:34 pm
Been thanked: 55 times

Re: Real floppy drive

Unread post by Lukage »

This will be fully opensource of course.
What about NTSC system frequency how its intended when in NTSC mode .. ?
It is the same circuit as for PAL. NTSC frequency is only slightly different, it does not matter.

I will continue with new board, probably ditching any prpgrammable device and use only some 74xxx. Also, how about USB 3 A connector on that, so the interface will plug directly into MiSTer user port, enabling to have floppy accessible on right side of MiSTer ?
retrorepair
Posts: 257
Joined: Sun May 24, 2020 9:06 pm
Has thanked: 64 times
Been thanked: 13 times

Re: Real floppy drive

Unread post by retrorepair »

I'd recommend 74HCT, but I probably don't need to say that :)

I do have a problem with mounting PCBs directly to the user port as I think it's a recipe for disaster, but I think I'm in the minority there. I guess a simple USB3 extension would work for those of us who don't want to risk damaging their ports :)

*EDIT* Are you planning to only support PC floppies or Amiga floppies too? Maybe with a jumper or DIP switch? I have a stack of either but love how raw a real Miggy drive sounds :)
Lukage
Posts: 49
Joined: Wed Aug 05, 2020 7:34 pm
Been thanked: 55 times

Re: Real floppy drive

Unread post by Lukage »

I think that both PC and Amgia floppies can be supported, but it needs to be accounted for inside FPGA.

I have a problem with USB3 connectors alltogether. If I use a cable, it is SO BIG ! Really, USB3A to USB3B has huge connectors. USB3A to USB3 micro is better, but still big. How about small PCB converting USB3A to pins ? Then flat cable to interface. Or both variants, so one can choose ?

I would like to mount floppy next to MiSTer in some case and do it as small as possible.
retrorepair
Posts: 257
Joined: Sun May 24, 2020 9:06 pm
Has thanked: 64 times
Been thanked: 13 times

Re: Real floppy drive

Unread post by retrorepair »

I think if you still have USB3 connectors on each board, it gives you the option to either use a PCB with vertical mount connectors to connect them (if your case and drive are a set height) or a cable.

However you think though, I'll just be happy it exists :)
Lukage
Posts: 49
Joined: Wed Aug 05, 2020 7:34 pm
Been thanked: 55 times

Re: Real floppy drive

Unread post by Lukage »

How about this ? It is still just a draft, but this way floppy drive could be placed on the right side of MiSTer, and it should fit nicely beneath the floppy adapter board.
Attachments
f.jpg
f.jpg (186.8 KiB) Viewed 27164 times
retrorepair
Posts: 257
Joined: Sun May 24, 2020 9:06 pm
Has thanked: 64 times
Been thanked: 13 times

Re: Real floppy drive

Unread post by retrorepair »

I still don't like the direct connection to the user I/O but I can use an extension so looks fine to me :)

Very tidy as well, is that an Altium render?

*EDIT* How are you thinking about handling power for the floppy?
User avatar
ron
Posts: 160
Joined: Sun May 24, 2020 7:02 pm
Has thanked: 70 times
Been thanked: 62 times

Re: Real floppy drive

Unread post by ron »

I have the impression that a Gotek floppy emulator would be a good complement, just like with physical computers
Great Work !
Lukage
Posts: 49
Joined: Wed Aug 05, 2020 7:34 pm
Been thanked: 55 times

Re: Real floppy drive

Unread post by Lukage »

Well, adding another USB-B, USB-microB or USB-C connector would be odd.... I think extension will work for those who want to have it somewhere else.

I didn't think of floppy drive power supply yet. There are floppy drives with 5V and 12V supplies, and there are floppy drives with 5V only. I didn't looked into DE10-Nano schematic yet, there are three options:

1) power it directly, it depends on user which floppy with which voltages is used
2) place a power input connector, floppy power output connector, and power MiSTer via this board
3) power 5V only drives from MiSTer

But I am just guessing now. I think the best would be to let user to decide. Right now the whole adapter board is powered from MiSTer via USB3 user port, so the only thing which is needed is flat cable to floppy and floppy power. MiSTer digital board have power input with switch, MiSTer analog board does not. I would not hesitate to try to power floppy via digital IO board, but I didn't look if it is possible and if it can handle such power. Same applies to DE-10 Nano.
Lukage
Posts: 49
Joined: Wed Aug 05, 2020 7:34 pm
Been thanked: 55 times

Re: Real floppy drive

Unread post by Lukage »

Just a quick update: It (almost) works !

I've managed to integrate floppy reader into Minimig core, modifying Paula functions to use physical floppy drive as DF2. DF0 and DF1 is still mounted via HPS as virtual floppy drives. As you can see in the attachment, I've managed to sucessfully insert Workbench 3.1 Install disk into physical floppy drive and read it on MiSTer ! As you can see on the other picture, I can read without errors all sectors on side 0 and side 1 on track 0 only. There is too big step when moving heads, my heads move to the end of the floppy in the middle of XCopy checking.

I do not know, if it is some kind of error on this one PC drive I am using, or some error in PC floppy connection. I do have more of them, and also some Amiga drives, but I will get to them on monday..... It seems that everything is working, but the head step is wrong. The movement and sound is beautiful ;)

I would like to test it with original Amiga drive to rule out any drive error, so I will take a day off tomorrow ;)

Also, I ordered parts for a prototype, but due to current world health situation, there will be substantial delivery delay.
Attachments
disk2.jpg
disk2.jpg (214.95 KiB) Viewed 26899 times
disk1.jpg
disk1.jpg (235.89 KiB) Viewed 26899 times
Lukage
Posts: 49
Joined: Wed Aug 05, 2020 7:34 pm
Been thanked: 55 times

Re: Real floppy drive

Unread post by Lukage »

Ahhhhh, I was utterly stupid and did some huge mistake in floppy drive output gating logic. It works, and I have my first full floppy read on MiSTer Minimig core from physical floppy drive !

Please note, that it is substantially slower than ADF read, it takes 23 seconds for XCopy to read whole virtual ADF floppy, while it takes full 1:15 minutes to read physical floppy !
Attachments
working.jpg
working.jpg (244.41 KiB) Viewed 26868 times
User avatar
toastboy
Posts: 69
Joined: Wed Sep 09, 2020 9:20 pm
Has thanked: 13 times
Been thanked: 20 times

Re: Real floppy drive

Unread post by toastboy »

Congrats on the first full read, really nice progress.
For power - I think you're right to leave it up to the user, and we'll all just head to ebay to find a 5v floppy drive :-)
[edit] samsung sfd-321b seems about right - 5v with 700ma max power consumption during seek.
https://manualsdump.com/en/manuals/sams ... b/168324/9
Obraxis
Posts: 9
Joined: Sun May 24, 2020 7:16 pm
Been thanked: 1 time

Re: Real floppy drive

Unread post by Obraxis »

This is very exciting! Certainly using real floppies or a Gotek drive with MiSTer would be superb.
bbond007
Top Contributor
Posts: 531
Joined: Tue May 26, 2020 5:06 am
Has thanked: 87 times
Been thanked: 211 times

Re: Real floppy drive

Unread post by bbond007 »

Obraxis wrote: Sun Nov 22, 2020 11:49 am This is very exciting! Certainly using real floppies or a Gotek drive with MiSTer would be superb.
I can understand wanting to use real floppies, but what would be the advantage of using a Gotek drive when the MiSTer Minimig core can read ADFs natively?
User avatar
kathleen
Top Contributor
Posts: 421
Joined: Fri Jun 26, 2020 4:23 am
Location: Belgium
Has thanked: 243 times
Been thanked: 138 times

Re: Real floppy drive

Unread post by kathleen »

@bbond007,
I was thinking the same than you, real floppy is really a nice and amazing add-on while the Gotek I was not really seeing the interest for the reasons that you mentionned.
But when I looked to my real Amiga which has only a gotek drive inside I review my thoughts.
Let's imagine that we do something on the real Amiga, can be a drawing under deluxe paint or write a test with a word-processor or whatever else, the only way to transfer it to the Mister is to use the .ADF saved to the Gotek of in my case the A500. This is of course possible by using the PC and transfer the .ADF to the Mister but having the Gotek directly hooked up to the Mister withdrawn this PC step.
But the interest is quite limited compare to read a real floppy directly usable on the Mister which I cannot wait to see it working

かすりん

User avatar
Reed_Solomon
Posts: 65
Joined: Sun May 24, 2020 7:37 pm
Has thanked: 40 times
Been thanked: 8 times

Re: Real floppy drive

Unread post by Reed_Solomon »

Nice progress. I'm impressed.
Post Reply