Instructables

HDDJ: Turning an old hard disk drive into a rotary input device

Featured

Step 4: Amplifying the output

Picture of Amplifying the output
P1040044.JPG
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).

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.
 
Remove these adsRemove these ads by Signing Up
enigmatik11 months ago
What is the purpose of 1k resistors in series with + signal?
isantos2 years ago
Instead of a LM324D, Can I use a LM386?
Lowkill3 years ago
Does the hard drive needs to be powered or I'm missing something here?
CBMalloch3 years ago
I'm somewhat confused. The sine waves show three phases spaced at 120deg apart, and this implies that the fourth wire is some kind of common. This conflicts with the idea of "pick any three", because one is special.

Then, the outputs of the comparators show two signals in quadrature (90 deg apart) and one signal that is the inverse of one of the first two. Doesn't seem like the same device is being shown.

With four wires all alike, I'd expect them to be 90 deg apart, so there would be two pairs of inverse signals, with one pair leading the other by 90 deg. With three wires and a common (wye) I'd expect the three wires to be at 120 deg apart.

Do your pictures represent two different disk drives, wired differently?

Thanks for the instructable -- I'm going to try it myself.
one prob though. Once the platter stops rotating it gets a little upity. the lights blink with the slightest vibration of the whole thing, but once the platter is rotated again, its running smoothly. I Imagine this oversensitivity could be corrected with a high value resistor, or low value capacitor
Just tested it, and it outputs the Grey Code as expected and behaves just like I imagined. Tesla would be proud :D
It should also give you some error detection. like, it is impossible for it to go from 11 to 00, or vise-versa, so you can tell it is misreading either by going too slow or too fast and ignore the reading
Hey, my HDD only had three wires (im guessing a motor in a "whye" config) but it gave me an idea. use the green wave as the reference for the other two (save urself an opamp) and it will output a grey code like a rotary encoder! this will also improve your resoloution since a 2-bit grey code has four states per revoloution, while your three-phase setup gives three per rev. it goes like this- Green wave is higher than other two= 00, green goes below red=10, yellow goes up above green allong with red= 11, red starts to fall below green while yellow stays = 01 - This pattern will repeat and give you four steps per rev while saving an exta op amp! ill try it out and let you know :D