I'm trying to drive a 24V BLDC motor using dual FETs only: the IRF7389 dual FETs. I'm not using any of the 3 Hall sensors, only controlling the on/off of the 6 transistors (n-channel + p-channel), according to the AN885 Application Note (look it up!) on BLDC Brushless Motor Fundamentals. Here's my code. Instead of plugging in the motor, I have 3 LEDs connected to the drain pins (5-8 on the IRF dual FETs) where the motor outputs are usually connected. So, this way, I do not fry the motor on the first attempt. All the p-channel sources are tied to 5V, while the n-channel sources are tied to GND. Of course, I have resistors at the gates and resistors in series at the drain pins. The problem is that the LEDs each light up one by one, the current initially spikes up to 250 mA and then drops back to 0A. Why??? How do I fix this problem? I'm too scared to plug in the motor in case it either burns up or doesn't spin at all.
const int q5=7;
const int q4=6;
const int q3=5;
const int q2=4;
const int q1=3;
const int q0=2;
void setup() {
pinMode(q5, OUTPUT);
pinMode(q4, OUTPUT);
pinMode(q3, OUTPUT);
pinMode(q2, OUTPUT);
pinMode(q1, OUTPUT);
pinMode(q0, OUTPUT);
}
void loop() { // Spin Clockwise
// Im using the table 3: AN885 application note.
// Sequence 1: q1 and q4 are high
digitalWrite(q5, LOW);
digitalWrite(q4, HIGH);
digitalWrite(q3, LOW);
digitalWrite(q2, LOW);
digitalWrite(q1, HIGH);
digitalWrite(q0, LOW);
delay(10);
// Sequence 2: q1 and q2 are high
digitalWrite(q5, LOW);
digitalWrite(q4, LOW);
digitalWrite(q3, LOW);
digitalWrite(q2, HIGH);
digitalWrite(q1, HIGH);
digitalWrite(q0, LOW);
delay(10);
// Sequence 3: q5 + q2 are high
digitalWrite(q5, HIGH );
digitalWrite(q4, LOW);
digitalWrite(q3, LOW);
digitalWrite(q2, HIGH);
digitalWrite(q1, LOW);
digitalWrite(q0, LOW);
delay(10);
// Sequence 4: q5 and q0 are high
digitalWrite(q5, HIGH);
digitalWrite(q4, LOW );
digitalWrite(q3, LOW);
digitalWrite(q2, LOW);
digitalWrite(q1, LOW);
digitalWrite(q0, HIGH);
delay(10);
// Sequence 5: q3 and q0 are high
digitalWrite(q5, LOW);
digitalWrite(q4, LOW);
digitalWrite(q3, HIGH);
digitalWrite(q2, LOW);
digitalWrite(q1, LOW);
digitalWrite(q0, HIGH);
delay(10);
// Sequence 6: q3 and q4 are high
digitalWrite(q5, LOW);
digitalWrite(q4, HIGH);
digitalWrite(q3, HIGH);
digitalWrite(q2, LOW);
digitalWrite(q1, LOW);
digitalWrite(q0, LOW);
delay(10);
}
In addition, are there any inherent delays in between each new "digitalWrite" command? I want the transistors in each sequence to either be on/off all at the same time.