Interfacing A Floppy Drive

Description

To read and write data directly to/from a floppy drive is quite simple.
Only a few of the pins are required to do this:

  • Index
  • Track 0
  • Read Data
  • Direction
  • Step
  • Write Data
  • Floppy Write Enable
  • Motor Enable A
  • Motor Enable B

A description of each pin's function follows.

Index

Outputs a pulse upon each full rotation of the disk.

Track 0

Becomes high when the head is at track 0.

Read Data

Outputs the data read from the disk.

Direction

To move the head inwards, set this low.
To move the head outwards, set this high.

Step

To move the head by 1 track in the direction set by the Direction pin, send a pulse to this pin.

Write Data

Send data to this pin to write it to the disk.

Floppy Write Enable

Set this high when writing to disk,
set it low when reading from disk.

Motor Enable A

Set this high to enable motor in drive A.

Motor Enable B

Set this high to enable motor in drive B.

All voltages are 5V.
All voltages are relative to 0V of the power input.
If you have not selected drive A or B, then set both Motor enable A and Motor enable B high.
The outputs may be open collector.

The following pseudo-code examples use all of the above pins and are intended to further explain the purpose thereof.

Comments are in this style

Write data pseudo code

Moves the head outwards by one track
StepOut:
Direction=HIGH
Step=LOW
Delay(1mS)
Step=HIGH
Return

Moves the head inwards by one track
StepIn:
Direction=LOW
Step=LOW
Delay(1mS)
Step=HIGH
Return

Start:
Data=0
Count=0

Turn on the motor and enable writing to the disk
Motor Enable A=HIGH
Motor Enable B=HIGH
Floppy Write Enable=HIGH

Move head to track 0
LoopA:
If Track 0=LOW Call StepOut

Loop until pulse detected on Index pin
LoopB:
If Index=0 Goto LoopB
LoopC:
If Index=1 Goto LoopC

Write Data to disk
LoopD:
Write Data=Data
Toggle Data between 0 and 1 to give 10101010…
Data=1-Data

If disk has not yet made a complete rotation, Goto LoopD
If Index=LOW Goto LoopD

Wait for end of Index pulse
LoopE:
If Index=HIGH Goto LoopE

Disk has now made one full rotation, so step the head in by one track and increment Count
Call StepIn
Count=Count+1

Goto LoopD if head is not on innermost track
If Count<31 Goto LoopD

At this point, head has reached innermost track, so disable writing to the disk and step head out until it reaches outermost track

Floppy Write Enable=LOW
LoopF:
StepOut
If Index=LOW Goto LoopF

End

Read data pseudo code

Moves the head outwards by one track
StepOut:
Direction=HIGH
Step=LOW
Delay(1mS)
Step=HIGH
Return

Moves the head inwards by one track
StepIn:
Direction=LOW
Step=LOW
Delay(1mS)
Step=HIGH
Return

Start:
Data=0
Count=0

Turn on the motor and disable writing to the disk
Motor Enable A=HIGH
Motor Enable B=HIGH
Floppy Write Enable=LOW

Move head to track 0
LoopA:
If Track 0=LOW Call StepOut

Loop until pulse detected on Index pin
LoopB:
If Index=0 Goto LoopB
LoopC:
If Index=1 Goto LoopC

Read data from disk to Data
LoopD:
Data=Read Data
Print Data

If disk has not yet made a complete rotation, Goto LoopD
If Index=LOW Goto LoopD

Wait for end of Index pulse
LoopE:
If Index=HIGH Goto LoopE

Disk has now made one full rotation, so step the head in by one track and increment Count
Call StepIn
Count=Count+1

Goto LoopD if head is not on innermost track
If Count<31 Goto LoopD

At this point, head has reached innermost track, so step head out until it reaches outermost track
LoopF:
StepOut
If Index=LOW Goto LoopF

End

Pinout

All directions are relative to drive.
(Pins marked "Input" are inputs to the drive)

idc34m.gif

idc34f.gif
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License