Controlling a floppy drive (designing a custom controller)

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
Hi all,

So today I have begun the effort of designing a floppy drive controller and have a question about data storage.

I have done a tonne of research and have print-outs of old documentation (so I am not being lazy ;) ). I connected up the floppy drive pins (34 of them) to their needed IO levels and sure enough, I could get the motor spinning, get the track 0 signals pulsing and read / write data to the floppy.

I do understand that FM is needed to store data (as the data is encoded not stored) because a change in magnetic field is what is recorded. But here is something I don't understand:

If I take a 500KHz square wave and feed this into the write pin then read the data I can clearly see the 500KHz wave. If I modulate this with some other square wave again I can see this from the output. What I don't understand is that if I hold the write pin high or low the data is left unchanged on the floppy. Is there some kind of AC coupling on the input pin? Surely if I hold this pin high or low the magnetic field produced should just align all the poles in some direction and result in the output to be totally flatlined?

All the best,
Robin
 

ronv

Joined Nov 12, 2008
3,770
Hi all,

So today I have begun the effort of designing a floppy drive controller and have a question about data storage.

I have done a tonne of research and have print-outs of old documentation (so I am not being lazy ;) ). I connected up the floppy drive pins (34 of them) to their needed IO levels and sure enough, I could get the motor spinning, get the track 0 signals pulsing and read / write data to the floppy.

I do understand that FM is needed to store data (as the data is encoded not stored) because a change in magnetic field is what is recorded. But here is something I don't understand:

If I take a 500KHz square wave and feed this into the write pin then read the data I can clearly see the 500KHz wave. If I modulate this with some other square wave again I can see this from the output. What I don't understand is that if I hold the write pin high or low the data is left unchanged on the floppy. Is there some kind of AC coupling on the input pin? Surely if I hold this pin high or low the magnetic field produced should just align all the poles in some direction and result in the output to be totally flatlined?

All the best,
Robin
No, it just overwrites the old data, no need to erase.
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
@ronv

That would make sense. I guess the only thing I can do then is use basic FM modulation (I don' want to deal with MFM right now) and just wipe the whole floppy with a square wave containing no modulation.

Also, does a floppy drive expect an encoded sine wave or an encoded square wave on the input? Best I could find was that the voltage levels on a floppy are 5V.
 

ian field

Joined Oct 27, 2012
6,536
@ronv

So why does holding the write pin low or high do nothing to the data stored on the floppy?
You could probably get most of the info from the NEC uPD785 datasheet and appnotes.

This was all bread and butter work from about the 70s.

There's various datasheets published by Western Digital that make informative reading, but they may be difficult to find now, and I can't remember the chip numbers.
 

ronv

Joined Nov 12, 2008
3,770
@ronv

That would make sense. I guess the only thing I can do then is use basic FM modulation (I don' want to deal with MFM right now) and just wipe the whole floppy with a square wave containing no modulation.

Also, does a floppy drive expect an encoded sine wave or an encoded square wave on the input? Best I could find was that the voltage levels on a floppy are 5V.
I'm a hard disk guy, so I may be wrong, but in a floppy I think the encoding is in the controller. The write IC may have a safety that detects no transitions. I would erase it with the highest write frequency. It is the easiest to overwrite. It is all digital. Will you still have sectors? Error detection/correction?
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
@ronv

Yup, I will have error detection (a crude one for now) and sectors too. In fact, you can't really do it without sectors XD
I plan to get this controller in a Xilinx XL9572 CPLD
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
@ronv
Sure I can do that! It's for my Z80 project where I intend to push the limits of a Z80 processor and see just how great a computer it can be made into. Of course, I will need a Z80 programmer to help me with OS related tasks. I am really not a software engineer, I like to make really complex hardware to give the CPU as much processing power it can have.

For example, my video card which does 320 x 240 monochrome relies on 0 CPU input with video generation, the video IC controller handles all of it!
 

Papabravo

Joined Feb 24, 2006
21,225
The Western digital chips were the 1771 and the 1791. The latter did MFM and the former did FM. Reading was done by an external data separator.
 

GopherT

Joined Nov 23, 2012
8,009
@ronv
Sure I can do that! It's for my Z80 project where I intend to push the limits of a Z80 processor and see just how great a computer it can be made into. Of course, I will need a Z80 programmer to help me with OS related tasks. I am really not a software engineer, I like to make really complex hardware to give the CPU as much processing power it can have.

For example, my video card which does 320 x 240 monochrome relies on 0 CPU input with video generation, the video IC controller handles all of it!
What is your plan for programming the Z80?
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
Thanks for the cool comments guys!

@GopherT
Programming the Z80 is done using a ROM, a ROM programmer and Z80ASM. I have created a customised c loader for SDCC so that I can write Z80 programs in C. To be honest, the system I have for the Z80 computer I built previously is better. It has a custom DOS which is written in assembler and programs that people can write for it is done in C. A user program should have an offset address of 32768 and this is taken into account with the custom C loader I made. The DOS loads the program in (using the MicroFAT format for I2C memory) and places the program at address 32768. Then the Z80 processor CALL's to the address because when the C program ends at the end of main() it runs a RET instruction which takes you back to DOS.

@Papabravo Thanks for that, will look into it :)

I know some of you are wondering why I am not obtaining a custom floppy controller, the answer is that I want to make a modern design (or one that uses new ICs). I don't really like the idea of using second-hand parts which rely on chips no longer being manufactured. That's why I had a heart attack when I found out that you can buy a 16bit processor, the W65C816S, which is still in production!
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
For those who are interested here is a signal test where I fed a 500KHz carrier wave modulated via FM with a 10KHz that adjusted the frequnency by 50%. The result was two waveforms on the read pin of 250kHz and 750kHz. This is raw data coming directly from the read pin on the floppy disk.




I am also designing the specification for the floppy controller to try and optimise for the PIC18 (as the controller) and the 8 bit bus for the Z80. So far I have the following spec:

  • 80 Tracks 2 Sides Floppy disks
  • 19 Sectors per track
  • 256 data bytes per sector (referred to as pages)
  • Three waveforms are stored on the floppy drive to represent 1, 0 and START
  • All three waveforms are 5us long
  • 0 is represented with 700kHz square wave
  • 1 is represented with 750kHz square wave
  • START is represented with 800kHz
  • START is used to sync the internal timers and initiate that we are on a new sector
  • Each sector has a single byte error detection. All bits on each nth bit are XORed
  • The PIC holds an entire page and is available on request - Removing the need for DMA
  • The PIC will hold current sector and track pointers

The initial plan seems to be rather basic and I have high hopes for it!
 

Attachments

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
Update:

I am currently making the controller on a single PIC and the results so far are promising. The PIC (clocked at 16MHz x 4 PLL for 64MHz @ 16MIPS) seems to be just fast enough for data encoding to the floppy. The real challenge, however, is reading off a floppy, writing is rather trivial.

But today I got the drive function and have a system that can wipe the data by sending a 250kHz signal through the write pin. It can do this for all the tracks on one side (still yet to implement side) and the controller can go to any track rather quickly. Format does take a while though :/

I also send it some data to store and I could read off it using a scope so that part is now working!

FUN FACT ABOUT FLOPPY DRIVES

Did you know that you can't move the head to different tracks if you are in write mode!



Reading the data saved to the floppy drive. 0's are long pulses @ 5us, 1's are short pulses @ 5us
 

Thread Starter

Robin Mitchell

Joined Oct 25, 2009
819
Having to redesign the code in assembler for max speed of the Pic ¬_¬
Also changing the data scheme from my version to standard FM
Each 0 bit is 1us low and 5uS high
Each 1 bit is 1us low then 2us high then 1 us low then 3us high
Start bits (sector idents) are just 800khz square waves


Fun discovery of the floppy

(As discovered from experimentation) did you know that if you hold the write enable pin low and stream data to the floppy the data is ignored if you pass the index hole. I tried wiping data by just holding down write enable and streaming 0's but it would not work if the index hole was reached. The problem is solved by waiting for index then writing until index is 0 again. When that happens you need to set write enable back to 1;
 

atferrari

Joined Jan 6, 2004
4,771
The Western digital chips were the 1771 and the 1791. The latter did MFM and the former did FM. Reading was done by an external data separator.
I could be dead wrong but I recall one of those chips ending in "3". It was the first I met after disassembling a disk.
 
Top