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.





