Arduino meets the Floppy Drive

Wednesday, 3 August 2011 Posted by Skylar

First, some history

Since the time when I wanted to build a CNC foam cutter, I've wondered if it would be possible to use the controller card found inside the 5 1/4" floppy drive.

Those early experiments were very successful, but all interfaced with the PC via parallel port. Although I managed to run 2 stepper motors simultaneously off 2 floppy controller cards, I was working in Pascal (DOS) and later Delphi. Then I encountered a huge obstacle - Delphi, being Windows-based, doesn't allow direct access to the parallel port. After some head-scratching, this hurdle was overcome by talking to the parallel port via "inline code" (Assembly language) from inside Delphi.

However, by then my interest in a CNC foam cutter faded and it never got built. I guess that I was more interested in the technical aspect, than to actually build and own a CNC foam cutter. In the meantime I had collected every TEAC floppy drive that I could find, as they contained very nice stepper motors (and controllers).

TEAC Floppy Drive controller & stepper motor

Fast-forward a decade and the parallel port is now ancient history, as new PC's and laptops don't have them anymore. As fate would have it, I was recently introduced to the Arduino through Sarfly, a local RC-model Yahoo group (thanks Wessie). So it was inevitable that sooner or later my Arduino endeavours would include playing with stepper motors.

Soon after blinking some LED's and firing up a LCD display, I mated the Arduino with a unipolar K179 stepper driver kit that I had built a year before. It worked, but with only full-stepping, the stepper motor vibrated too much for the intended application - an equatorial platform for my telescope. Then, urguing that micro-stepping would alleviate this unwanted phenomenon, I ordered the EasyDriver from Sparkfun. This proved to be a good move, as it solved the vibration problem.


video


Arduino meets the Floppy Drive

However, the floppy controller still haunted me and finally, the Arduino and floppy controller were introduced to each other. The meeting went well and it works as expected, although only full stepping is possible. But I'm sure it will find it's way into some other project eventually, as I still have have all the floppy drives that had been accumulated over the years.


Card Edge Connector on the Floppy Drive

Connecting the floppy controller to the Arduino

  1. Pin 12 (Select 1) on the floppy controller's card edge connector needs to be grounded. I simply soldered a short piece of wire between pin 12 and a pin on the other side of the card edge connector, since all uneven-numbered pins are ground.
  2. Connect Pin 16 (Drive Motor Enable) to a digital pin on the Arduino. (I used pin 8).
  3. Connect Pin 18 (Direction) to a digital pin on the Arduino. (I used  pin 12).
  4. Connect Pin 20 (Step) to a digital pin on the Arduino. (I used pin 13).
  5. The last connection is to ground the floppy controller to the Arduino. I soldered a wire to the back of the card edge connector (any uneven-numbered pin) and connected it to ground on the Arduino.


Power

The floppy controller card needs both 5v and 12v. I connected the red wire on the Molex plug to 5v on the Arduino. For the 12v supply, you can either use a PC PSU, but I found that if the PSU is hooked up while uploading a sketch, the USB port is lost temporarily. To solve this, I opted to use a battery connected to the yellow (+12v) and black (ground) wires on the Molex plug. This is where a spare 3S LiPo comes in handy.

With all the connections made, all that's left is to upload the Arduino sketch below and test.


Code

/****************************** FloppyStepper ******************************** 
******************************************************************************
* Drives a 5 1/4" floppy drive stepper motor using the on-board driver card. *
*                                                                            *
* http://skylar-arduino.blogspot.com/2011/08/arduino-meets-floppy-drive.html *
******************************************************************************

  The circuit:
  * pin 12 (select 1) to ground 
  * pin 16 (enable) to digital pin 8 (on Arduino)
  * pin 18 (direction) to digital pin 12 (on Arduino)
  * pin 20 (step) to digital pin 13 (on Arduino)
  */

  //Constants
  #define DELAY 3200  // sets speed

  // Stepper pins
  int enable_pin = 8;   
  int dir_pin = 12;     
  int step_pin = 13;    

void setup() {
  // Initial setup of pins   
  pinMode(dir_pin, OUTPUT);
  pinMode(step_pin, OUTPUT);
  pinMode(enable_pin, OUTPUT);
}

void loop() {
  digitalWrite(enable_pin, HIGH);
  delay(1);   
  digitalWrite(dir_pin, HIGH);  // clockwise
  delay(1);  
  perform_step(200);            // perform 200 steps
  delay(500);
  digitalWrite(dir_pin, LOW);   // anti-clockwise
  delay(1);   
  perform_step(100);            // perform 100 steps
  delay(500);
  perform_step(100);            // perform 100 steps
  delay(500);  
}

void perform_step(long steps) {
  for (long i=0; i < steps; i++) {
    digitalWrite(step_pin, LOW);
    delayMicroseconds(100);
    digitalWrite(step_pin, HIGH);
    delayMicroseconds(DELAY);
  }
  // Set the pin low before we end
  digitalWrite(step_pin, LOW);
}
References:
Controlling floppy stepper motors from FTDI USB chips in bitbang mode
http://pinouts.ru/Storage/5_12_floppy_pinout.shtml 
Labels:
  1. Skylar, I followed your directions and for some reason the stepper will turn anti-clockwise but not clockwise. Any idea what it could be?

  2. I understand what you mean. However, I have no idea what the solution is.

    The reason for my blog is only to demonstrate that it’s possible to use the on-board electronics to drive a stepper motor.

    I won’t be able to trouble-shoot your problem, sorry.

  3. Monitor Pin 18 on the floppy control board, and see if it's transitioning from low to high.
    This pin selects the direction. If it's going to the wrong pin on the arduino, or not connected at all, or if the arduino isn't toggling it, you will only get one direction...and NOBODY likes ONE DIRECTION.

Post a Comment