17

I've recently found a more modern application "Floppy Disk Master-7"(Picture 2) (FDM) that visualized the bad sectors, tracks and clusters(Picture 1) on a floppy disk in a similar (but fancier) way to the older "Norton Disk Doctor"(Picture 3) (NDD).

This raised the following question: How do both applications know the start of the first sector and the end of a the last sector of a floppy disk, in order to accurately visualize it on an image (FDM) or progress-like bar (NDD)? When is the disk in the proper direction visualized, assuming sector 1 starts at position twelve-o'clock on the left visualization and on 0% in the second visualization. Or more broadly how does a floppy drive (driver) identify the unique sectors?

Also if I understand it correctly the formatting type(Picture 4) determines the sector structure so in order to analyse and visualize the bad sectors, firstly the formatting type needs to be determined and understood in order to visualize?


Floppy disk Sectors, Tracks and Clusters

Picture 1: Floppy disk Sectors, Tracks and Clusters

Floppy Disk Master 7

Picture 2: Floppy Disk Master 7

Norton Disk Doctor

Picture 3: Norton Disk Doctor

Floppy Disk Format Apple Floppy Disk Format

Picture 4a: Floppy Disk Format 4b: Apple Floppy Disk Format

1
  • 1
    this is C64 specific: youtube.com/watch?v=_1jXExwse08 but it'll give you an extremely detailed view of how the floppy is organized; AFAIK, none of the 8 bits use the index hole and all read to find the right sector. I highly recommend that video.
    – Thomas
    Jan 15 at 12:37
23

The track identification part is quite simple. Floppy formats are standardized so that there are specifications what is the distance between tracks (e.g. 96 tracks per inch) and what is the position of the tracks from some reference point, so the drive is designed accordingly so that moving the head one step will always step one track, and the heads are aligned during drive manufacture so that they land on the tracks correctly as per the specification. The floppy drive has a stepper motor and it actually does not know at which track the heads are currently moved to, so it is the floppy controller that keeps track of where the head is positioned.

The floppy drive can only detect with an end switch when the heads are moved to track 0 and this status is made available to the floppy controller. When booting up a machine, if the floppy controller detects that the drive is not positioned to track 0, the heads are moved towards track 0 one step at a time until the drive says the heads are now positioned at track 0.

The sectors are more complex. It is not the floppy drive that knows anything about sectors either. For the drive, a whole track with all the sectors on it look like an endless loop with no start or end.

All the drive does is reads the magnetic transitions on the track to the floppy disk controller, and also writes data from floppy disk controller to the track.

Typically the drive also provides an index pulse signal once per rotation to the disk controller which may use the information to do something, like start formatting a track when the index pulse arrives, but it is not essential to normal read or write operation, but it is useful for aborting an operation if it has not succeeded for a few rotations.

When a floppy track is formatted by the controller, typically the controller would wait for the index pulse and then write the whole track in one continuous operation, writing all the sectors, with appropriate preambles and synchronization marks, and with properly timed gaps between sectors. Each sector consists of two parts, first there is a sector ID header which gets written with info such as which track this is, what is the sector number, and how many bytes the sector data contains. Then after a gap, there is sector data header which follows with the sector data and CRC check word. As the index hardware pulse starts the track formatting, sometimes there is also an index data mark written right at the beginning of a track, to mark the beginning of a track in the data stream.

So when the controller is commanded to read one or more sectors starting from some specific area of the drive, it would seek to correct track, select correct read head (top or bottom side), and starts listening the data stream for the correct sector header and when it has been detected the sector data is passed on to system one way or another (IO or DMA). This would continue if more than one sector needs to be read.

Please note that the order in which the sectors are on a track is set during track formatting. For a floppy that has 18 sectors per track, they could be in any order on the track. In some systems the tracks were not organized linearly, but interleaved so that if the system can't read two consecutive sectors, at least there is no need to wait for a full rotation until the sector with the next number is again under the head and available for reading.

So it is unlikely that these software programs actually know how the sectors are physically located on a track. Most likely they work with just the logical sector number. This can be seen from the images that the programs don't even care that 1.44MB floppies were two-sided, and that for NDD it uses 3 sectors per one symbol for the status.

So, just for reading and writing floppy images or checking for bad sectors, it is irrelevant how they are visualized versus how the sectors really are physically located on each track. To the software, an 1.44 MB floppy is just a block device with 2880 sectors of 512 bytes each and they can be accessed without problems or then there is a problem which can be visualized.

13
  • 9
    Many floppy drives don't have sensors for track 0 nor the index hole. Track 0 may be located by simply running the stepper motor out 40 tracks, letting its motion be blocked by the end stop. Sectors may be placed starting at an arbitrary rotational position, and missing sectors may be dealt with via timeout.
    – supercat
    Jan 14 at 15:46
  • 2
    @supercat re the index hole, I've never heard of it not being used on 5.25" disks anyway. That's surely why we needed to punch another hole in the envelope in order to use disks in single sided drives the wrong way up (that and the write protect notch) to use the reverse side. Is my memory failing me?
    – abligh
    Jan 16 at 9:32
  • @abligh, I agree for 5 1/4" disks in PCs and earlier CP/M machines. Same for 8" disks.
    – grahamj42
    Jan 16 at 10:37
  • @abligh: Purpose-designed drive controller chips often rely upon the index hole, but machines from Apple and Commodore that use drive controllers built from discrete chips often ignore them.
    – supercat
    Jan 16 at 16:03
  • @abligh: I think there may be a mentality among the chip manufacturers that a disk controller should affirmatively indicate that a track doesn't contain a header for a certain sector, and shouldn't assume a hard-coded rotational speed, but people who design drives as an integrated hardware/software system recognize that software can take care of such things.
    – supercat
    Jan 16 at 16:05
8

Where there are various formatting schemes for floppy disks, the usual is to break down a track into sectors. This is done during formatting and the individual sectors are written with empty data in them along with "buffer" zones between them.

Each of the sectors typically has an "address" that in incorporates the SIDE, TRACK, and SECTOR numbers.

When the disk is being read or written the controller needs to find the exact side, track, and sector where the data is to be read from or written to. It does this by starting to read sectors until it finds the one with the address being looked for and once it does it either reads the data block from that sector or switches on the write circuitry to write the data block.

Most disk systems have what is called an "index" hole or mark which is used to help the drive locate sector one quickly without having to read. The controller waits until the index is located and then it knows that sector 1 is under the R/W head.

Note that there are many variations of the above scheme but most follow this pattern to one degree or another.

4

TL;DR:

For the titular question:

A floppy drive doesn't identify anything at all (some may to track 0). For tracks it steps in or out as much as the controller tells. It also doesn't identify sectors but read the raw magnetic stream. it is the controller that looks for data blocks, picks headers thereof and acts according to whatever address is written there.

For the workings of the programs mentioned:

They simply read the floppy using OS calls to deliver one or more sectors within a track.

Some advanced (modern) can do more like low level reading and measure time to show real distribution.


How do both applications know the start of the first sector and the end of a the last sector of a floppy disk,

By simply reading it?

The shown programs work by reading logical sectors with the usual OS calls. They simply read each sector in ascending order, from 0 to max (as set by the OS) using the OS function to read a sector - the very same way as any other access does.

in order to accurately visualize it on an image (FDM) or progress-like bar (NDD)?

Reading is all done on a logical level and, except for the very last picture, they display only an assumed, logical structure, not a real distribution. These images are abstract representation of the data gathered to make reading easy, not really low level positional information.

When is the disk in the proper direction visualized, assuming sector 1 starts at position twelve-o'clock on the left visualization and on 0% in the second visualization. Or more broadly how does a floppy drive (driver) identify the unique sectors?

Like it is always identified when reading, by it's header?

Also if I understand it correctly the formatting type determines the sector structure so in order to analyse and visualize the bad sectors, firstly the formatting type needs to be determined and understood in order to visualize?

No, it doesn't. At least not for those basic graphics.

Format information is provided by the OS. Neither of the programs bypasses the OS when reading. It's just the high level information presented in a nice circle or sequence of blocks.


Now, of course it's possible to do a more in depth analysis by using direct, low level hardware access. Programms doing so will need their own floppy drivers on modern OS (*1), while on classic DOS they would simply operate FDC and timer direct. This would start by direct reading a track. Either using a read track command and analyse the data stream delivered by the FDC or reading each sector of a track while measuring access time.

Positioning of sectors relative to each other can be calculated from the read data when reading track, or from a timer counting. Relative positioning between tracks can as well be based thereon, as disk rotational speed is constant. At least as long as the drive doesn't stop inbetween :))

Of course it may be useful to determinate the exact speed an individual drive is running at first. This can easy be done by reading the same sector (like the first one) twice and measuring the waiting time between these two reads - better to do that a few times to get a more reliable measurement.

By measuring each access time for each sector on each track a nice picture of the real distribution can be drawn - unlike the abstract ones offered by NDD or FDM.


*1 - Some information could be gathered without a dedicated driver by timing based guessing ... err ... statistics, but this depends quite a lot on OS behaviour.

3
  • Starting at Windows Me, Microsoft simplified driver access to basic devices by abstracting the hardware layer for basic operations. Prior to that, and in Unix variant OS's you are able to communicate more directly with the hardware itself. Any generic application is simply showing a representative picture. Even that last one. I would be surprised if you intentionally damaged a disk in a pattern if it show up on that screen. Jan 16 at 12:36
  • @RowanHawkins I'm not really sure what you mean by 'intentionally damaged a disk in a pattern [...]Even that last one'? If you reffer to image 4b, then there is no damage. it shows a common distribution of sectors of a soft sectored format - that is when the OS does not honour the index hole (quite common). Tracks bear a skew due to head movement time during formating.
    – Raffzahn
    Jan 16 at 17:01
  • open the shutter, press hard... draw an x in ball point pen, read the disk. Jan 17 at 4:55
2

How do both applications know the start of the first sector and the end of a the last sector of a floppy disk, in order to accurately visualize it on an image (FDM) ...

Having a look at the screen shot from the website of the manufacturer, I doubt that this is an accurate visualization of the floppy:

A real floppy disk track begins with some empty space, then the sectors (each one consisting of the address field, data and empty space) follow and at the end of the track there is more empty space.

The screen shot however shows 18 sectors that cover 1/18 of the full circle - this means that there is no empty space on the visualization.

I assume that the program is assuming that a floppy disk with N sectors per track contains sectors 1, 2, ... N in each track. And it assumes that the sectors are stored in that order.

The floppy disk format (e.g. 1.44 MB) is stored in the first sector of a disk and it is known that a 1.44 MB disk has 80 sectors per side and 18 sectors per track.

However, the sectors can be stored in a different order (e.g. 1, 10, 2, 11, 3, 12 ... 9, 18) or even use completely "odd" sector numbers (e.g. 53, 35, 39, 120, 97, 87, ...). I assume that the program would not visualize such disks correctly at all.

... or progress-like bar (NDD)?

If you are talking about screen shot #3:

This is a linear visualization of sectors:

This kind of visualization is not "accurate" at all but it simply displays all sectors accessed by the operating system in the order in which they are accessed by the operating system (DOS or Windows).

If you modify a 1.44 MB (2880 sectors) floppy in a way that the OS treats it as 720 KB (1440 sectors) floppy, the program will probably only show 1440 of 2880 sectors.

1

Sectors are nothing new

Computers had them with magnetic tape.

A "sector header" was a quasi-unique pattern that shouldn't occur anywhere else in data.*

So the drive simply waited until a sector header appeared, then read the sector in the normal manner. The sector header included the sector number. If it wasn't the sector desired, then go back to waiting.

Like I say, this is nothing new; it'd been done for years with magnetic tape.



* What keeps someone from writing data with a sector header in the data pattern? A reality of magnetic media's difficulty recording long strings of hard zeroes or hard ones. You were already adding more bits to the data stream to assure all write patterns had an appropriately mixed 0-1 pattern. So for instance an 8-bit byte might actually write as 10 media bits - so 00000000 might map to 0011010010 to assure there were enough 0-1 transitions in the data for it to record reliably. Thus, mappings could be chosen to exclude certain combinations reserved for sector headers.

Tracks are "Go to zero, then use dead reckoning"

The heads are positioned off a gear or worm drive operated by a stepper motor. The stepper motor is electronically controlled to a precise rotation angle.

It's pretty simple: if your density is 96 tracks per inch, then use a threaded worm drive with 96 threads per inch. Have the stepper motor do one complete revolution to move 1 track over. As long as the stepper motor stops at 0 degrees, and this is easy to ascertain/hold with a stepper motor, it should be right on-track.

By comparison, a typical screw from an electrical junction box is 32 threads per inch.

Obviously there were refinements to this, such as using 48- or 24-thread-per-inch and stopping the motor every 180 or 90 degrees. The trade-off being precision vs speed. Or moving away from steppers altogether.

Drives generally used "dead reckoning" to know where they were. If they were on track 24 and made 3 inward steps, they must necessarily be on track 21.

However at some point (always: startup), the drive will not be sure about its position. In this case, it ran the head inward, until it reached track zero. There was a mechanical limit switch that would close when the head reached track zero.

Some cheaper drives did not even have a limit switch, and simply rammed the head repeatedly against the mechanical track zero stop. These drives were particularly noisy in their "seeking to zero" on startup and when they encountered a bad sector!

1
  • I don't think I've seen floppies with gears or worm drives. More typically, a stepper motor turns a wheel which has a piece of spring steel around the perimeter that unwinds as the drive head moves.
    – supercat
    Jan 17 at 15:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.