/* Tim Anderson robot@mit.edu feb 1999 do robotics without spending money or building circuits. Get some foppy drives out of old pcs that people throw away. build the spindle motor and headposition stepper motor into a robot or kinetic sculpture. Hook the "step", "direction", and "motor enable b" pins from the drives to your computer's pll ports. Now you can write a program that will move the stepper motor to whatever positions you want, and turn the spindle motor on and off. With a couple of pll ports you can control four drives worth of motors. this example program controls one. It will compile on a borland or microsoft compiler, and probably djgpp too. gnu rules! */ #include //outp #include //printf //what the pll port pins are used for: // there are 25 pins on the printer port. They are numbered in a wacky way. Often the tiny pin numbers // are next to the pins in the plastic of the connector. // there are 34pins on the floppy drive connector. the odd numbered ones are all ground. // that is the backside of the card-edge connector on the drive. // pin numbers on this connector refer to the ribbon cable that connects to it. // the drive's cardedge connector has the pins numbered alternately, that is, odds are on the back side. // evens are on the front. The ribbon connector magically puts them in numerical order in the cable. // the ribbon cable has stripe on one edge. that's pin one. // cut this ribbon cable, cut a printer cable, strip the conductors you need, and wire them together // thus: #define ENB 0x01 //pll port pin 2 is hooked to floppydrive pin 16 "MOTOR ENABLE B" #define DIR 0x02 //pll port pin 3 is hooked to floppydrive pin 18 "DIR" //a single pin of the pll port didn't seem to pull the signal to a low enough voltage. // use two pll port pins to sink more current. #define STEP (0x04|0x08) //pll port pins 4 and 5 are hooked to floppydrive connector pin 20 "STEP" //hook pllport pin 18(ground) to floppydrive pin 1(ground) and floppydrive pin 12 "drive select b" //I'm assuming the floppydrive is jumpered as "drive B". Most of them are. The twisty part of the cable //maked one of them into a "drive a" as far as the pc you butchered was concerned. // if you have a "drive a" on your hands, ground pin 14"drive select a" instead. // actually it probably wouldn't hurt to ground both these pins. Experiment! // plug the floppy drive into the powersupply that came with it or the powersupply on your computer. // no smoke or sparks come out because you followed the directions and I typed correctly. // You have finished your electronics project. Now we make it move! #define PORT 0x378 //address of lpt1 //#define PORT 0x278 //address of lpt2 short byte; void help(void){//explain what the keyboard does printf("hit Q to quit \n" ); printf("E,e: enable,disable spindle motor \n" ); printf("D,d: set,reset headmotor direction \n" ); printf("2: step headmotor \n" ); printf("3: toggle headmotor direction \n" ); printf("byte is = %x \n", byte ); }//help void main( void ){ int i; long j; short key, done=0; //all floppy drive signals are active-low outp(PORT, byte=0xFF );//turn everything off help(); done=0; while (done!=1){ if (kbhit()){ key = getch(); switch(key) { case 'E': printf("enabling \n"); outp(PORT, byte=byte&~ENB); break; case 'e': printf("enabling \n"); outp(PORT, byte=byte|ENB); break; case '2': printf("stepping \n"); outp(PORT, byte=byte&~STEP ); printf("byte is = %x \n", byte ); for(j=0; j<1000000; j++);//countup to a big number to make a wide step pulse. doesn't need to be this wide. outp(PORT, byte=byte|STEP ); printf("byte is = %x \n", byte ); break; case '3': outp(PORT, byte^=DIR); printf("changing direction = %d \n", (byte&DIR)>0 ); break; case 'D': outp(PORT, byte|=DIR); printf("setting direction = %d \n",(byte&DIR)>0 ); break; case 'd': outp(PORT, byte&=~DIR); printf("resetting direction = %d \n",(byte&DIR)>0 ); break; case ' ': case '?': case 'h': case 'H': help();break; case 'q': case 'Q': done = 1; break; default: break; }//switch }//if kbhit }//while !done printf("now done. bye. \n"); outp(PORT, byte=0xFF );//turn everything off }//main