Jump to content


Photo

Floppy Emu: an SD Card Floppy Emulator


  • Please log in to reply
57 replies to this topic

#1 bigmessowires

bigmessowires
  • 68000
  • LocationSan Francisco Bay Area, CA

Posted 19 November 2011 - 03:46 PM

After a lot of tinkering, my Macintosh 400K/800K floppy emulator is finally ready! Yesterday I got read-only floppy emulation working from an SD card, in a rough approximation of the originally intended design. That makes it possible to download disk images of classic Mac software from the web, copy them to an SD card, and load them onto a Mac Plus or other Macintosh using the Floppy Emu.

[attachment=0]floppyemu2.png[/attachment]

You can use the emulator to boot a Mac, or boot from a normal disk and then mount the emulated floppy to copy files from it. I even copied an emulated disk using Disk Copy 4.2 on a Mac Plus, and explored all the sectors using FEdit, so I'm pretty confident that it's working right.

Unlike other floppy emulators that I know of, Floppy Emu uses an on-the-fly sector retrieval technique instead of a track-at-a-time technique. This technique only requires a single 512 byte buffer, enough for one sector. After the data bytes from a sector have been sent to the Mac, the microcontroller loads the next sector from the SD card, which takes about 2 milliseconds. On a real floppy the sector-to-sector padding is only about 0.25 milliseconds, but it turns out that the Mac is tolerant of much longer inter-sector delays as long as you keep sending it $FF sync bytes between sectors.

In its current form, Floppy Emu appears 3x slower than a real floppy disk, but I think that's due to a bug rather than the SD card overhead. Using Disk Copy 4.2, I was able to read an entire 800K floppy in 41 seconds, and an emulated version of that same floppy in 2 minutes 10 seconds. As best as I can tell, the difference is due to some kind of bug that’s triggering the Mac’s retry mechanism. The display screen shows the emulated active track and side in real-time, so I can see that after every few tracks read during disk copying, the drive seeks down to track 0, then all the way back up to the track where it left off. This looks like some kind of mechanism for coping with unexpected data: the Mac concludes the drive isn’t where it thought it was, so it resyncs by returning to a known location (track 0) and then continuing.

My next steps are to pretty this up a little, add some basic UI for selecting disk images from the SD card, and fix the bug that's causing the retry slowdowns. After that, implementing write support for emulated floppies will be the next task. That will require a different micontroller and different technique than the one used currently.

More details are on my blog if anyone's interested.

/edit/ Also available: the development thread, Design ideas for a floppy drive emulator. - Bunsen /

Question to the 68kmla.org community? How important do you think write support is for something like this? I plan to implement it eventually, but it may be a big challenge. Is there enough value in a read-only floppy emulator?

#2 bbraun

bbraun
  • 6502

Posted 19 November 2011 - 03:56 PM

There is absolutely value in a read-only version to me! I enjoy older computers, but I have a special dislike of old media.

#3 dougg3

dougg3
  • 6502

Posted 19 November 2011 - 06:33 PM

Woohoo! That is nifty, BMOW!

I agree with bbraun -- this device is very useful in its current read-only state. Anything that gets us farther away from the floppies and closer to modern storage accessible by a modern computer is definitely worth it!

#4 olePigeon

olePigeon
  • 68LC040

Posted 19 November 2011 - 07:13 PM

Man, I'm super jealous of you guys. You're just pumping out the coolest tech. Way to go!

If you finalize the design, would it be possible to build and sell an IDE adapter so people with, say, an LC or Mac II with a 2nd floppy drive could put an SD card in it?

#5 superpantoufle

superpantoufle
  • 6502
  • LocationYvonand, Switzerland

Posted 19 November 2011 - 07:56 PM

Impressive! bigmessowires, I'm lurking your progress here and on your blog since the beginning of this project. All of this is awesome! Incredible!

But I must say that, imho, a read/write floppy emulator make more sense to me. Your read-only prototype is already unbelievable (as is all the Plus Too project), for sure! But a mean to get data easily out of our old Macs without having to mess with floppies / external hard disks / Zip / LocalTalk or whatever seems a must to me! 8-)

Again, I'm not the guy who'll design it. But if it's feasible, along the Plus Too, I would say go ahead with read/write!
From a Macintosh SE to a MacBook Pro 13'' (late 2009). 23 years of (insanely great) addiction, and counting.

Pomme-S.ch :: my collection hosted on a PowerBook 145B.
Takalyde.ch :: Indie-rock from Switzerland

#6 bigmessowires

bigmessowires
  • 68000
  • LocationSan Francisco Bay Area, CA

Posted 19 November 2011 - 08:18 PM

Yup, I'll definitely keep working towards a read/write version. I was more wondering whether it was worth it to develop the read-only version as a separate device, since it might be easier to build or cheaper to make, and it could be ready pretty soon vs the unknown development time for a read/write version.

would it be possible to build and sell an IDE adapter so people with, say, an LC or Mac II with a 2nd floppy drive could put an SD card in it?

.

I'm not sure what you mean by an IDE adapter? Those Macs have SCSI ports that you could buy a SCSI to CF adapter for. The Mac II has an external floppy port so it could also use Floppy Emu, but I think the LC doesn't.

If you mean the internal floppy connector, then yes that should definitely be possible. It's the same interface, just with a different physical connector. I'm not sure how you'd run the cable outside the Mac's case, but you could probably rig up something.

#7 ClassicHasClass

ClassicHasClass
  • 6502
  • LocationElectron Alley

Posted 19 November 2011 - 10:49 PM

I'd gladly take a read-only device. #creditcardiswaiting

#8 olePigeon

olePigeon
  • 68LC040

Posted 20 November 2011 - 12:30 AM

I'm not sure what you mean by an IDE adapter?


I assumed the CF card reader was IDE, and I meant going from the IDE CF card reader to floppy connector. Sorry, I'm not thinking too clearly.

#9 Bunsen

Bunsen

    Admin-Witchfinder-General

  • Administrators
  • LocationMelbourne, Australia

Posted 21 November 2011 - 03:58 AM

It's SD, not CF.

have you searched? Seeks: Nubus PDS DSP PB170 Newton; TRS-80 III/4; CBM BBC SX-64 CX5M Likes: 8bit luggable palmtop terminal NC tablet audio MIDI analog FM drum synth steam&dieselpunk; 1930-1980 lab/comm/mil Score! NC100 PB190 Q950 IIe-PDS


#10 Bunsen

Bunsen

    Admin-Witchfinder-General

  • Administrators
  • LocationMelbourne, Australia

Posted 21 November 2011 - 04:23 AM

Here's a possibly silly thought-

Would it be feasible to control the mcu from the host Mac via say zterm? That might make the LCD redundant, and allow an invisible "stealth" installation on the internal floppy connector. One would need to have zterm on the Mac already ...

or

have the FlopEmu default to the first image, and have a bootable system with zterm on there.

I note that you have a nice colour GLCD on your prototype. Is that just one you had handy? I was thinking the final could maybe use something cheaper, like those 1-bit mono Nokia knockoffs? Also suitably retro :)

have you searched? Seeks: Nubus PDS DSP PB170 Newton; TRS-80 III/4; CBM BBC SX-64 CX5M Likes: 8bit luggable palmtop terminal NC tablet audio MIDI analog FM drum synth steam&dieselpunk; 1930-1980 lab/comm/mil Score! NC100 PB190 Q950 IIe-PDS


#11 bigmessowires

bigmessowires
  • 68000
  • LocationSan Francisco Bay Area, CA

Posted 21 November 2011 - 05:39 AM

Yes, I only used that display for the prototype because it happens to have an SD card socket on the back, and I already had left over from another project. The 1-bit Nokia display clone was exactly what I had in mind. Actually I was thinking to make the display optional, with a couple of status LEDs or something for feedback if you don't want to pay for a display.

Probably not zterm, but some kind of custom software on the Mac could theoretically be used to view and select disk images. I think the HxC Floppy Emulator works that way, with a host-side control tool for the Amiga and Atari ST. Really there are a ton of cool things that could be done from the software end, like a custom disk driver to enable disks larger than a real floppy, or multiple disks from a single device. That's not really where my experience or interest lies though. I'm hoping that if I get some working hardware out there along with good documentation, somebody else might be interested in the software hacking part. :)

#12 Bunsen

Bunsen

    Admin-Witchfinder-General

  • Administrators
  • LocationMelbourne, Australia

Posted 21 November 2011 - 11:50 AM

Well, the idea of using a terminal emulator just occurred to me as a way of avoiding writing custom Mac software. The mcu could just send and receive ASCII text for menus to display at the Mac end and user choices sent back.

have you searched? Seeks: Nubus PDS DSP PB170 Newton; TRS-80 III/4; CBM BBC SX-64 CX5M Likes: 8bit luggable palmtop terminal NC tablet audio MIDI analog FM drum synth steam&dieselpunk; 1930-1980 lab/comm/mil Score! NC100 PB190 Q950 IIe-PDS


#13 bigmessowires

bigmessowires
  • 68000
  • LocationSan Francisco Bay Area, CA

Posted 22 November 2011 - 08:22 PM

OK, I think I've fixed the bug that was causing all the retries and reseeks to track zero, bloating the read times. Now it reads through an entire floppy image without any retries-- hooray! But it's still slower than a real floppy: 57 seconds to read a 800K disk, vs 41 for a real floppy in my most recent test.

I'm wondering if this has something to do with how the sectors are interleaved and organized on a real floppy. On my emulated floppy, the sectors in each track appear in consecutive ascending order, and every time the drive steps or switches sides, it jumps to the first sector on that track. I'm wondering if real floppies are formatted with a 2:1 interleave, so sectors appear in order like 0 4 1 5 2 6 3 7 instead of 0 1 2 3 4 5 6 7. I also seem to remember reading somewhere that a real floppy offsets the location of the first sector in each track from the location of the first sector in the previous track.

There are a bunch of tricks like that which can help reduce the number of times the disk must make a complete rotation before the Mac reads all the sectors from a track, basically trying to match the access pattern of the Mac with the organization of the sectors on the disk. In a perfect world, the Mac would always read all the sectors from a track in one pass, with the disk only making a single rotation. My debug info shows this does happen with my emulated floppy, but only rarely. With a real floppy this should be rare too, because it would require the lucky chance of a read operation beginning just as the first sector of the track approached the read head. With a random starting position, two rotations of the disk should always be enough to read the whole track, assuming the Mac is fast enough to keep up. But my debug info shows that most of the time, it takes about three "rotations" of the emulated disk to read a whole track. My measured disk read times of 57 vs 41 seconds make roughly a 3:2 ratio, so maybe there's something to that.

#14 jongleur

jongleur
  • 6502
  • LocationSydney, Australia

Posted 22 November 2011 - 08:38 PM

Slightly slower read/access times to me are acceptable. I'd be more interested in the disk image management on the SD card, preferably through a display on the reader, to drill through to, then select the required disk image.

What are the chances this could expand to a HD20 (or any size disk image) emulator? Of course as disk image size increases, then access time improvements become important again. Ahhh, the vicious circle of development prototyping.

#15 techknight

techknight
  • 68LC040

Posted 23 November 2011 - 03:05 AM

ya, maybe you can put it in a small style enclosure, with some buttons and a 2x20 line text LCD display, probably cheapest/easiest.
Main PC: Intel core I7 920, MSI x58 platinum, Radeon4850
PB: tibook G4, ibook G4, ibook g3x2, Lombard, 160, 165, 180, 180c Duo 2300x2, Duo 270c x2, 520cPPC, 3400c, 1400c
Desktop: G3AIO, SE, SE/30, 512k, plus, LCIII, iMac G4, iMac intel, 6400/225

#16 bigmessowires

bigmessowires
  • 68000
  • LocationSan Francisco Bay Area, CA

Posted 23 November 2011 - 09:28 PM

Surprisingly, the 84 x 48 Nokia LCDs are actually cheaper than your typical 2-line text LCD, and they require fewer pins to control too. http://www.sparkfun.com/products/10168 The only downside is they all seem to have problems getting the contrast right, as it somehow varies depending on the temperature and force between the LCD and the circuit board. I have two of them, and they both change contrast if you push on the LCD frame with your finger. But for a $10 serial graphical LCD, I can overlook that.

I've got it using the Nokia LCD now instead of the color TFT, and everything is working pretty nicely for read-only emulation. I'm only able to go up to a 4 MHz data rate with the SD card, but I think that's due to my messy breadboard wiring. Viewed on the oscilloscope, the clock signal looks pretty bad, so I'm not surprised it doesn't work at higher speeds.

I'm going to start work now on a custom circuit board for this thing, which should hopefully improve the signal quality too and make faster data rates possible.

#17 techknight

techknight
  • 68LC040

Posted 24 November 2011 - 02:16 AM

$10 is not bad, not bad at all. Well if you wanted fancy, could do a VFD :-)
Main PC: Intel core I7 920, MSI x58 platinum, Radeon4850
PB: tibook G4, ibook G4, ibook g3x2, Lombard, 160, 165, 180, 180c Duo 2300x2, Duo 270c x2, 520cPPC, 3400c, 1400c
Desktop: G3AIO, SE, SE/30, 512k, plus, LCIII, iMac G4, iMac intel, 6400/225

#18 Bunsen

Bunsen

    Admin-Witchfinder-General

  • Administrators
  • LocationMelbourne, Australia

Posted 24 November 2011 - 04:02 PM

a small style enclosure

Well, just for giggles, how about aiming, size-wise, to fit the PCB into an Apple external 3.5" floppy drive case? Dead drives could be updated with the new SD drive. And it's about the same size as a small project box, so one of them could be used instead where the genuine article is not available.

Hm. Speaking of which, various people on the other thread were requesting a version for the Powerbook 100 and Duo floppy port, which uses a different connector. Others mentioned internal mounting - different connector again. Is it worth designing the board such that all three connection types can be accommodated? I would be happy to help chase up dimensions etc if you wish.

have you searched? Seeks: Nubus PDS DSP PB170 Newton; TRS-80 III/4; CBM BBC SX-64 CX5M Likes: 8bit luggable palmtop terminal NC tablet audio MIDI analog FM drum synth steam&dieselpunk; 1930-1980 lab/comm/mil Score! NC100 PB190 Q950 IIe-PDS


#19 jongleur

jongleur
  • 6502
  • LocationSydney, Australia

Posted 24 November 2011 - 10:01 PM

just for giggles, how about aiming, size-wise, to fit the PCB into an Apple external 3.5" floppy drive case?

Giggle me not. Damn great suggestion!!

#20 techknight

techknight
  • 68LC040

Posted 25 November 2011 - 02:10 AM

Yea, and the LCD/keypad/SD card could slide out of the "slot", well if you wanted it fancy, you could make a motorized slide rail so when the mac "ejects" the disk, the display/keypad/sd assembly slides out. When a image is selected to be mounted, it slides in. LOL ok now im getting all "hollywood"
Main PC: Intel core I7 920, MSI x58 platinum, Radeon4850
PB: tibook G4, ibook G4, ibook g3x2, Lombard, 160, 165, 180, 180c Duo 2300x2, Duo 270c x2, 520cPPC, 3400c, 1400c
Desktop: G3AIO, SE, SE/30, 512k, plus, LCIII, iMac G4, iMac intel, 6400/225




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users