You are on page 1of 10

Home Sign Up!

Explore Community Submit

HDDJ: Turning an old hard disk drive into a rotary input device
by nvillar on November 10, 2008 Table of Contents intro: HDDJ: Turning an old hard disk drive into a rotary input device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . step 1: Crack open a hard disk drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . step 2: Solder wires to the spindle motor contacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . step 3: Probing the motor output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . step 4: Amplifying the output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . step 5: Measuring direction and velocity of spin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . step 6: Schematics and firmware for the HDDJ device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . step 7: Video summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Customized Instructable T-shirts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 3 4 4 5 6 7 7 7 7 8 8 8

http://www.instructables.com/id/HDDJ_Turning_an_old_hard_disk_drive_into_a_rotary/

intro: HDDJ: Turning an old hard disk drive into a rotary input device
A couple of years ago we built a fun system that would allow DJs to mix music tracks in interesting ways. Our design called for an input device that would allow the DJ to quickly seek through a track and find a specific playback position, and we wanted to be able to do this by spinning a rotary control with a flick of the wrist - much like turntable DJs can spin the record back and forth to do the same. We found that we had only limited choices for building our device: we first tried to use rotary encoders, but it is not easy to find a cheap encoder that spins smoothly and freely. Another alternative was to buy some audio equipment (like turntables) that spin well and feel good to use - but this seemed both expensive and wasteful for our purposes. Then, while looking for inspiration amongst assorted junk in the lab, we came upon a broken hard disk drive with its case open. We admired the quality of the bearings in the motor that drives the disk plates, enjoyed the fact that even a soft flick would get it spinning for a long time, and wondered whether we could sample an output from it when it was spun by hand, in much the same way that an electric motor, when turned, acts as a dynamo and outputs a voltage. The answer is yes - and it's a very simple process to turn a hard disk into a rotary input device that has some unique properties. All you'll need is an old hard disk drive, a few op amps, resistors and a programmable microcontroller of some kind. In this Instructable we'll show the basic principles behind this hack, then provide the schematics and firmware for the HDDJ device (shown below) that we used in our project, and which includes a few extra buttons, lights and a motorized slider for good measure.

step 1: Crack open a hard disk drive
Old, unwanted or broken hard disk drives (HDDs) are usually free and easy to get hold of. They come in all shapes and sizes, but the most common are the 3.5" HDDs that are used inside desktop PCs. We experimented with a number of different 3.5" HDD models, and found that most are suitable for our purposes (and would guess that smaller, laptop-sized disks would work just as well). The largest variation lies in how easy it is to open the case of some compared to others. Seagate HDDs, which often use plain Phillips screws in the casing, are our favorite. The first step is to open the drive by removing all the screws that hold the case closed. Often these are torx screws, and you'll need an appropriate screw driver. Sometimes a screw will be hidden behind a label - so if you have trouble opening the case after all the screws seemed to have been removed, poke at the labels to find the culprit. If there is a label saying "Warranty Void if Removed," then, for sure, remove it. Open the case, and reveal the disk platters in all their untouched glory. Never again will they be so free of fingerprints. Remove the actuator that holds the read-write head, which stops the platters from spinning around freely. It's up to you how much more you want/need to remove (rule of thumb: anything sharp should go). The only thing that you need to keep attached are the frame, platters and spindle motor. Thanks to Wikipedia for the Anatomy of a Hard Disk Drive"" image.

http://www.instructables.com/id/HDDJ_Turning_an_old_hard_disk_drive_into_a_rotary/

Image Notes 1. Unscrew 2. Unscrew 3. Unscrew 4. Unscrew 5. Unscrew 6. Unscrew 7. Unscrew 8. These three were hiding under the label.

step 2: Solder wires to the spindle motor contacts
Turn the HDD over, with the exposed platters facing down. Some older HDDs will have four wires coming out of the back of the spindle motor, in which case you can skip this step. Most, however, have an orangy-transparent flat-flex cable. In this case, what we are looking for are four exposed contacts at the back of the motor that we can solder some wires to.

Image Notes 1. We could solder four cables to these four points. 2. Or we could solder here.

Image Notes 1. You'll probably want to solder much longer cables than these.

http://www.instructables.com/id/HDDJ_Turning_an_old_hard_disk_drive_into_a_rotary/

step 3: Probing the motor output
This is not really a necessary step, but more an illustration of what exactly we are trying to do. If you have a access to an oscilloscope with multiple inputs, connect three of them to three of the wires soldered to the spindle motor contacts in the previous step (it doesn't matter which three). Connect the probes' ground clips to the fourth wire, then set the platter spinning. The scope images below show the three waveforms that are generated when the HDD platter is spun by hand (the scale is set to 500mV per division in the vertical axis, and 20ms per division in the horizontal axis). Three perfect phase-shifted sinusoidal waveforms! The three different pictures show what happens to the waveforms as the platter gradually slows down: they all decrease in both frequency and amplitude by the same amount. These waveforms carry a lot of information, not only how fast the platter is spinning, but also in which direction it is spinning (clockwise, or anti-clockwise). More on this later. The raw signals, as generated by spinning the motor by hand, are simply too subtle to be sampled directly by a microcontroller, so the next step is to amplify them into useful levels.

step 4: Amplifying the output
Now you have signals coming from your HDD's spindle motor, it's time to amplify them, and in the process convert them to square waves that can be fed into a microcontroller. The amplification can be done with a simple comparator circuit. Each comparator (the triangles in the schematic) has two inputs (+ and -) and one output. When the voltage on the (+) input is less than the voltage on the (-) input the output will be pulled down to the negative supply voltage, otherwise it will be pulled to the positive supply voltage or, depending on the model of comparator, float at high impedance (in which case a pull up resistor is required). In the schematic below we have wired an LM324D opamp to function as a comparator (an explanation of how this works can be found here). The LM324D includes 4 comparator modules in a single package, which is perfect because in our case we need three (the 4th is not shown in the schematic). One of the lines from the HDD is used as a reference, and is connected to the (-) inputs of all the comparators. The other three lines are connected to each of comparators (+) inputs. Not shown in the schematic, but also important, are the power supply pins of the comparators. The negative supply is connected to ground, while the positive supply is connected to Vcc (in our case +5V).

http://www.instructables.com/id/HDDJ_Turning_an_old_hard_disk_drive_into_a_rotary/

When the voltage of a signal pin from the HDD is greater than the reference the comparator output will be +5V, otherwise it will be ground. The outputs of this circuit (second image) can now be connected directly to the input pins of the microcontroller.

step 5: Measuring direction and velocity of spin
In this step we take the outputs from the amplifier circuit in step 4 and input it to a microcontroller to convert them to something a bit more useful. The images below show the output from the amplifier circuit as the HDD platter is spinning at various decaying velocities. As the velocity decreases the period of the wave increases. The first two images below show the platter turning in different directions. If we look at order in which the rising edges of the waves occur we see that in the first image (spinning clockwise) it's Yellow Blue Pink, whereas in the second (spinning anticlockwise) its Yellow Pink Blue. The code for the microcontroller watches the inputs from amplifier for a rising edge. It also keeps track of which inputs the last two rising edges occurred on (we'll call the inputs Y, P and B). If we detect a rising edge on input Y, and the previous rising edge was on P and before that B, we know that the platter is spinning clockwise, same for P, B, Y and B, Y, P. Conversely if we detect a rising edge on Y, and the previous two rising edges were on B and P respectively, we know the direction is anticlockwise, and same for B, P, Y and P, Y, B. Any other combinations are regarded as noise and ignored. In our implementation we use a PIC microcontroller. The inputs from the amplifier are connected to the interrupt pins of the microcontroller; these generate an interrupt on the rising edge of the input. Our code then looks at which input generated the interrupt and which inputs generated the last two interrupts. If a clockwise spin is detected a '>' character is output to the PC, if an anticlockwise spin is detected a '<' is output. Because the frequency of the interrupts depends directly on the frequency of the waves, which is proportional to the speed of the platter the computer software can work out the velocity of the platter from the frequency at which it receives '<' or '>' characters.

http://www.instructables.com/id/HDDJ_Turning_an_old_hard_disk_drive_into_a_rotary/

step 6: Schematics and firmware for the HDDJ device
For our original DJing project we equipped the hard disk drive with eight additional buttons, six LEDs and a motorized fader to make the HDDJ device. We designed a custom circuit board and wrote some firmware that allowed us to connect all these controls (plus the input from the HDD platter) to a PC via USB. Here you can download the files needed to recreate this design in EAGLE format, plus the firmware that needs to run on the PIC microcontroller (youll need a suitable PIC programmer to do this). How to test the HDDJ Device 1. Install the driver provided in the ZIP file 2. Plug in the HDDJ to a USB port of your computer (it will mount as a virtual serial connection, and assign it a COM port) 3. Use a terminal program (like Putty) to connect to the COM port, at 115200bps, 8 data bits, no parity bit, and one stop bit. 4. Try spinning the HDDJ platter: you should see a stream of '<' characters appear as it spins counter-clockwise, and '>' characters as it spins clockwise. The frequency of characters will depend on the velocity of spin. 5. Moving the fader will output the character 'f' followed by a number between 0 and 100. To control the position of the fader type the character m into the terminal window, followed by a number between 0 and 100, and then hit return. 6. Pressing the buttons will output the character 'b' followed by a number between 0 and 8. To turn the LEDs on and off type the character l into the terminal window, followed by a number between 0 and 6, and then hit return. For our project we wrote a bit of software that communicated with the HDDJ via the USB serial line using this protocol. It would be a relatively small (but useful) step to adapt it to, for example, translate the control sequences MIDI messages, which would let you use the HDDJ with generic music or VJ'ing software out of the box.

http://www.instructables.com/id/HDDJ_Turning_an_old_hard_disk_drive_into_a_rotary/

File Downloads
HDDJ.zip (210 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'HDDJ.zip']

step 7: Video summary
Here we have a video summary, showing the HDD connected to: 1. A comparator circuit, which amplifies to the output from the motors. 2. An oscilloscope, which shows the nice amplified square waves. 3. A microcontroller, which takes the square waves as input and uses them to determine the direction of spin. The microcontroller outputs (via serial line) the "<" character while the disk is spinning counter-clockwise, and the ">" character when it is spinning clockwise. 4. A computer, that takes the output of the serial line and shows it on the screen. In the video we're pretty excited because we just got this working for the first time :)

Video

Related Instructables
Several Easy Steps to Boost Your Computer's Speed by lukethebook333

Op-amp headphone amplifier by neelandan

Upgrading your new laptop from Vista to XP by VIPER2475

Make a Simple Audio Amplifier by zabi_rauf

Predictive* digital music synthesizer (Pandora's Box #2) by VIRON

Make Music Controlled Christmas Lights by gigafide

Modded Xbox incorporated into a Scion TC by richiehops

Cup-Motor Speaker by Brennn10

http://www.instructables.com/id/HDDJ_Turning_an_old_hard_disk_drive_into_a_rotary/

Advertisements Customized Instructable T-shirts

Comments
23 comments Add Comment

Brett_cgb says:
Nice project – I think I’ll replicate it (the portion that uses the disk motor as a flywheel controller).

Nov 15, 2008. 1:32 PM REPLY

I suspect that the common Neg reference for the LM324 should be connected to one of the other pins on J2 (whichever one you used for the 3-phase scope captures), and that it should be biased to 0.25Vdd (one quarter Vdd – see the LM324 requirements for input signals). This raises the reference and all the motor phases to within the supply rails of the LM324. Ideally, you would see a 3-phase digital representation of the 3-phase motor signals. Firmware needs to see any two phases to determine speed and direction. When one phase rises, this triggers a step. Check the state of the other phase to determine direction.

terramoto says:
hey could you reply the full components list? thanks

Nov 15, 2008. 11:48 AM REPLY

windserfer says:
I'm sorry it is possible to have more detailed instructions? the

Nov 15, 2008. 7:33 AM REPLY

t.rohner says:
Good idea and a very nice oscilloscope you have...

Nov 14, 2008. 11:26 PM REPLY

crazytiti says:

Nov 14, 2008. 9:29 AM REPLY realy good instructables thank you, i will take one hdd to make a sound volume controller, i will follow your system : put an lm324 then an USB pic with serial emulator then i will use "GIRDER" (a good soft which can take many system as input and then create windows events)

natman says:
wat program is that???

Nov 13, 2008. 10:19 PM REPLY

Dash_Merc says:
This is a very good write-up, but I'd like to see a little more explicit description under the how-to area of this project.

Nov 13, 2008. 9:21 AM REPLY

Furthermore, are there any plans to include either driver software (if not, I can figure that out, too) and/or a performance demo video? I want to see the lag time on this baby. Thank you for the inspiration. I'm going to make myself a couple of these, and figure out how to make them compatible with the HID protocol (yes, MIDI is okay and possible, but HID is smoother and faster) and Traktor.

Coffee bean says:
DUDE u have it put it to music and then u can say u remixed your hard drive.

Nov 13, 2008. 4:22 PM REPLY

gabrielG2 says:
What DJ software are you using?

Nov 13, 2008. 3:00 PM REPLY

http://www.instructables.com/id/HDDJ_Turning_an_old_hard_disk_drive_into_a_rotary/

TheNemo says:

Nov 13, 2008. 2:28 PM REPLY Very nice project. I have been looking for something like this for quite some time. Many other approaches were too complex for me to get my feeble mind around, but this one is clear and straightforward. I'll have some good fun with it I'm sure. Most of the stuff I have lying around, and I think you could do this easily with an Arduino and Processing.

kylemcdonald says:

Nov 13, 2008. 6:35 AM REPLY Nice idea. I like the reuse of the case/mounting/disks and augmenting something that had an alternative use in its previous life. I feel like the original sine waves could be decoded by a microcontroller, though, without any intermediary hardware. And probably with better resolution than 1 bit (i.e., forward or backward).

DanOverholt says:

Nov 13, 2008. 4:33 AM REPLY Hi - great project, nice work! I noticed you might be interested in translating the data output from your project into MIDI, and thought I would mention that such firmware is available for my CREATE USB Interface - CUI http://www.create.ucsb.edu/~dano/CUI/ - that sends MIDI-over-USB and would be able to control many music/VJ packages out of the box. It is for the PIC18F4550, the "big brother" of your PIC18F2550 of course, but it's just a matter of changing the processor type #include and recompiling. Of course, it would be simple to put the opamp in the prototyping section of a CUI board, so this would also be an easy project for those that have an old hard drive and a CUI laying around...

hazzalflame says:
could you give us a complete list of tasty ingredients please and thank you!!!

Nov 13, 2008. 12:03 AM REPLY

sypher says:
that is awesome, that is quite ingenious.

Nov 12, 2008. 10:28 PM REPLY

LinuxH4x0r says:
Sweet! 5/5

Nov 12, 2008. 9:29 PM REPLY

Arx says:
Weight it, and drive it at 33 or 45 rpm and it'll be really good for the DJs. :)

Nov 12, 2008. 9:00 PM REPLY

chipboy says:
SO IS THIS TECHNICALLY A CDJ U CAN SCRATCH AND TREAT AS 1

Nov 12, 2008. 6:19 PM REPLY

GorillazMiko says:
That's incredible! I gotta try this out. Hope to see more projects from you! +5/5 stars. (added to favorites)

Nov 12, 2008. 6:15 PM REPLY

westfw says:

Nov 12, 2008. 5:52 PM REPLY Neat. In an interesting bit of synhcronicity, you might also check out this other recent project on using stepper motors in a similar manner. http://home.clear.net.nz/pages/joecolquitt/stepper_as_encoder.html One of the interesting discoveries there was that you can increase "cogging" of your input device by putting some bias power through your windings. And you can simultaneously operate the motor as a motor...

tyler_durden says:
Great! Why didn't I think of this? Did you check the number of pulses per revolution?

Nov 12, 2008. 4:33 PM REPLY

ker-boom101 says:
so technically this is a working turntable that can be hooked up with a computer to Dj? if so could i know the quality of the scratching??

Nov 12, 2008. 2:24 PM REPLY

http://www.instructables.com/id/HDDJ_Turning_an_old_hard_disk_drive_into_a_rotary/

knexfan9182 says:
''''''' hi'''''

Nov 12, 2008. 1:27 PM REPLY

crapflinger says:
....NIFTY! if you haven't already started...are you going to post one for the cubic crossfade? that thing looks nifty!

Nov 12, 2008. 12:17 PM REPLY

http://www.instructables.com/id/HDDJ_Turning_an_old_hard_disk_drive_into_a_rotary/