Wednesday, July 11, 2012

Repurpose an Old Disk Drive as a Microcontroller Input Device

Every geek either has and old disk drive or soon will. Here is a way to repurpose that disk drive as an input device for a microcontroller project. This example just shows the disk drive blinking an LED. But you get the idea; with some creativity there are many applications. It's so easy it barely qualifies as a hack, but here are the details.
-----
The device that makes a disk drive spin is a DC spindle motor. If you spin the spindle motor a current is produced. Search youtube for LED Stepper flashlight, etc. and you will find many examples of this experiment.

We need to get two of the spindle motor wires on the disk drive ultimately into the microcontroller.  Take the drive apart and make connections to two of the spindle motor wires.  In the pic you see where we soldered small wires to middle spindle motor connection points.  The other end of these two wires are soldered to two of the drives header pins. This makes for a handy way to plug in a JST connector.

-----
Below is a 'scope shot of what the output signal looks like when you spin the spindle motor.  A purist might consider rectifying the output to keep the microcontroller from seeing a negative voltage.  Since the max output is maybe 500mV, I didn't worry about it.
-----
Here is the custom code for the microcontroller; a PICAXE-08M2.  An Analog to Digital Convertor (ADC) input is monitored.  If a signal is detected of the ADC from the spinning disk drive then flash an LED.  Short and simple.

#picaxe08m2
low 2                'LED on output 2.  Make certain it is off
main:                'Start of main program loop
readadc 1, b0   'Read value of ADC on input 1.  Store in b0
if b0 > 1 then   'If there is a signal on the ADC, the disk is spinning so LED on
toggle 2
pause 50
endif
goto main
----
Thanks for the visit!!!
-----
Link back: Hack A Day
-----