Hard disks spin via a three-phase brushless motor through a driver operating at 12V. Normally, the driver is operated by the hard drive microcontroller, which ensures the quick acceleration at startup and the constant velocity, typically 5400rpm or 7200rpm. Since the motor operates synchronised to the frequency of the pulses, if this frequency is kept constant, then the drive speed is kept constant as well.
I build a drive using an old hdd using an STM32 microcontroller. The hardware is fairly simple. You need a 12V supply (can be a UPS battery or a PC power supply), a full bridge driver (I used a L298), a pulse generator (STM32F429 discovery) and of course the hard drive.
Now the first thing you need to do is to determine the hard drive connections. The motor has 4 cables (three phases and the neutral). The neutral is not needed. To determine which is which, a multimeter can be used. The three phases need to be connected to the output of the full bridge driver. My bridge had 4 outputs (for a stepper motor), I only needed three.
So, the next thing is to generate the pulses to drive the motor. The motor operates synchronously, so the speed is determined by the frequency of the pulses. Therefore, to accelerate the motor, the frequency must increase gradually. The pulses are simple 50% duty cycle pulses, with 120 degrees phase difference.
In the designed program, the controller has a reference speed of 9000rpm and it gradually accelerates the hard drive to reach the reference speed (the nominal speed of the drive is 5400rpm). There are also touch buttons on the screen which will change the reference speed of the drive. So, two timers were used: One (TIM2) to generate the 120degree phase difference pulses and another (TIM3) to control the acceleration of the drive, depending on its speed. In lower speeds, a rapid acceleration will desynchronise the drive. The same applies to very high speeds. A closed loop can be implemented (by optically measuring the drive speed or by measuring the EMF of the winding that is not used), however the system works sufficiently well even without it.