HDD Motor with voltageread sensor?

Dear fellow makers,

I am a complete noob when it comes to arduino and its code. I just got started with it. I'm trying to control an HDD motor. Apparently all codes available on the internet do not work with my hard drive. With those codes, they're hard to start up and starts decelerating after a certain 'digital gear'.

So I thought, why not 'make' a sensor, like the ones ESC use. When the permanent magnet induces a small voltage across one of the three coils, I can choose to give the other two coils a pulse.

The setup, standard MOSFET setup (IRF3205) to pulse the 3 coils, I am still waiting for appropriate diodes to come in, therefore now I am using LEDs as diodes to protect my MOSFET. Basically the setup is exactly the same as here (figure 4): The amateur Programmer: Revitalizing old hard drive motors using Arduino

The only adjustment/add on:

I used the basic voltage read code from arduino with using A0-2 for the three wires. I connect ground* to the positive external voltage supply. This way when I spin the rotor by hand, I see a voltage spike of 0.1-0.3 volts. In the code I let the two other coils fire when voltage spike is 0.3 to make sure there is litte noise affecting the voltage measurement. This way I know exactly what the rotor position is relatively to the other coils.

*Not sure if this is the right way of connecting the arduino when measuring voltage.

This method works perfectly, I do need to spin up the rotor by hand to at least 0.3 volt. After this, it speeds up until (what I believe the coils get saturated). This is around 3.3-3.7 volts from the external power supply. When I turn up the voltage the RPM goes down, when I decrease the voltage the RPM slowly goes down. Sweet spot is around 3.3 volts.

I tried to built in the Frequency Measure code, it did not work properly.

My question is, at what 'default' hz am I reading the voltage, also how can I speed up the voltage reading and therefore the pulses to make the motor run faster. How do I turn the voltage reading into a standard on/off signal with build in noise reduction (the more voltage is generated the higher the voltage needs to be to be read as 'on' at rpm=0 I put it at minimum 0.3 volts). How do I properly inject a frequency measure code to get the rpm. When knowing the RPM (from the voltage read) and the voltage read minus noise, I know exactly when to pulse. I however have no clue how to 'translate' this into a code.

This is the code I managed to put together using parts of different codes:

const int phase1pin = 2;
const int phase2pin = 3;
const int phase3pin = 4;
const int delayTime = 0; // microsecs

void setup() {
pinMode(phase1pin, OUTPUT);
pinMode(phase2pin, OUTPUT);
pinMode(phase3pin, OUTPUT);
}

void loop() {
// read the input on analog pin 0-2:
int sensorValue1 = analogRead(A0);
int sensorValue2 = analogRead(A1);
int sensorValue3 = analogRead(A2);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage1 = sensorValue1 * (5.0 / 1023.0);
float voltage2 = sensorValue2 * (5.0 / 1023.0);
float voltage3 = sensorValue3 * (5.0 / 1023.0);
// print out the value you read:

if (voltage1 >0.3){
switchStep(2);
switchStep(3);
}
if (voltage2 >0.3){
switchStep(3);
switchStep(1);
}
if (voltage3 >0.3){
switchStep(1);
switchStep(2);
}

}

void switchStep(int stage){
switch(stage){
case 1:
digitalWrite(phase1pin, HIGH);
digitalWrite(phase2pin, LOW);
digitalWrite(phase3pin, LOW);
delayMicroseconds(delayTime);
break;
case 2:
digitalWrite(phase1pin, LOW);
digitalWrite(phase2pin, HIGH);
digitalWrite(phase3pin, LOW);
delayMicroseconds(delayTime);
break;
case 3:
digitalWrite(phase1pin, LOW);
digitalWrite(phase2pin, LOW);
digitalWrite(phase3pin, HIGH);
delayMicroseconds(delayTime);
break;
}
}

Hi,

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

The MOSFETs are not LogicLevel devices, the 5V from the arduino will not completely turn the MOSFET ON.

You will also need 220R or 470R series resistors in the gate circuit and 10K resistors connected from gate to source.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks Tom.... :slight_smile:
The code tags present you sketch in a scrolling window instead of a long page.