Floppy disk drive hacking: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
I recently got a bunch of 5-1/4" 40 track, double sided floppy drives off eBay for some reason. These drives are very old, and not in the best condition. I got lucky though, and in testing them on a floppy controller inside a computer, several of them worked straight away, formatting disks properly with no issues. | I recently got a bunch of 5-1/4" 40 track, double sided floppy drives off eBay for some reason. These drives are very old, and not in the best condition. I got lucky though, and in testing them on a floppy controller inside a computer, several of them worked straight away, formatting disks properly with no issues. | ||
For the drives that did not work right away, I needed some way to diagnose them; MS-DOS just assumes the disk is bad and says "Track 0 bad." I also wanted to check the alignment of the drives, however, the original alignment disks that technicians used are long gone. I wanted to try connecting an Arduino to a floppy drive and try to write a repeating pattern to a disk. Then, I could check the output from the heads or /RDATA pin to make sure the disk is being read correctly. | For the drives that did not work right away, I needed some way to diagnose them; MS-DOS just assumes the disk is bad and says "Track 0 bad." I also wanted to check the alignment of the drives, however, the original alignment disks that technicians used are long gone. I wanted to try connecting an Arduino to a floppy drive to control stepping between tracks, and try to write a repeating pattern to a disk. Then, I could check the output from the heads or /RDATA pin to make sure the disk is being read correctly. | ||
To begin, I connected all the inputs from the disk drive to digital outputs on an Arduino Mega. The floppy drive interface works at a very low level, more like a tape recorder than a modern hard drive. | To begin, I connected all the inputs from the disk drive to digital outputs on an Arduino Mega. The floppy drive interface works at a very low level, more like a tape recorder than a modern hard drive. |
Revision as of 18:55, 16 February 2020
I recently got a bunch of 5-1/4" 40 track, double sided floppy drives off eBay for some reason. These drives are very old, and not in the best condition. I got lucky though, and in testing them on a floppy controller inside a computer, several of them worked straight away, formatting disks properly with no issues.
For the drives that did not work right away, I needed some way to diagnose them; MS-DOS just assumes the disk is bad and says "Track 0 bad." I also wanted to check the alignment of the drives, however, the original alignment disks that technicians used are long gone. I wanted to try connecting an Arduino to a floppy drive to control stepping between tracks, and try to write a repeating pattern to a disk. Then, I could check the output from the heads or /RDATA pin to make sure the disk is being read correctly.
To begin, I connected all the inputs from the disk drive to digital outputs on an Arduino Mega. The floppy drive interface works at a very low level, more like a tape recorder than a modern hard drive. These pins were:
- /Motor enable - turns on the disk motor when LOW
- /Drive select - tells the drive it's supposed to be being used, so activate your output pins.
These two pins are just set LOW when the Arduino starts up, so we start off with a drive that is selected and rotating the disk.
- /Direction - Set the direction to move the heads
- /Step - a pulse on this pin moves the heads on track over. Doing this repeatedly is how people make those musical floppy drive videos.
- /WGate - enables writing to happen on the disk
- /WData - data to write. Each one of these pulses is written as a pulse onto the disk.
- /Head - select either the top or bottom head to write/read.
I also connected the index and the track0 signal to the Arduino (on an input-pullup pin), though I haven't used them for anything yet.
The Arduino is far too slow to actually read data from the drive. To do that, I'll hook up one of those cheap $20 USB logic analyzers, which seems to be fast enough at 12 M samples/second to read all data from the disk. With the index and track0 signals, and stepping through each track, we could conceivably read the raw data from entire floppies, like a Cryoflux or similar tool.
Alignment / Read/Write test
The trick here is to connect an analog oscilloscope to the /RDATA pin, so we can see the live signal as the disk rotates. Then, we need to write a repeating pattern onto the disk so that the oscilloscope can display it properly.
I made the signal using the Arduino; an Atmega at 16Mhz is barely fast enough to do it, using direct port writes to make the data write pin turn on and off, and a bunch of assembley NOP instructions to do delays of a couple microseconds, but it isn't perfect. Every now and then the waveform gets interrupted, presumably as the processor checks something else (related to loops?), but it's still good enough for the oscilloscope display.
I actually did 2 signals, one at 200kHz and one at 250kHz, which I write to alternating tracks and heads. That way, I will see an alternating pattern on the scope as I move from track to track, and head to head on the same track. The signals aren't straight square waves, they are more like low pulses of about 1uS, with the remainder of the time High.
I used this technique to discover why one of my drives was malfunctioning - instead of /RDATA reading one pulse per flux change (normal operation), I was getting two pulses - a low-high-low instead. Very strange behavior, and I'm not sure what is causing it, but at least now I know what is going on instead of the simple "Track 0 Bad" or "General Failure" messages.