Hello everyone, i'm a student working on a project on creating a custom controller to my Ebike Planetary BLDC Motor 36V 350W. i've created the Inverter using IRF540N MOSFET to my BLDC and also created the Driver using IR2101 IC that will be driven through Arduino UNO, both of them are references i found on the Internet. Before i created all of them i make sure my circuit running well so i simulated it in Proteus (i'll attach the picture), also inside proteus i program my Arduino UNO and it worked fine, i also learned the 6 commutation steps to become the base of my Arduino program. here's my program:
const int HallApin = 7;
const int HallBpin = 6;
const int HallCpin = 5;
const int potPin = A0;
int HallAState = 0;
int HallBState = 0;
int HallCState = 0;
const int D2pin = 2;
const int D3pin = 3;
const int D4pin = 4;
const int D9pin = 9;
const int D10pin = 10;
const int D11pin = 11;
int Kecepatan;
void setup() {
pinMode (HallApin, INPUT);
pinMode (HallBpin, INPUT);
pinMode (HallCpin, INPUT);
pinMode (potPin, INPUT);
pinMode (D2pin, OUTPUT);
pinMode (D3pin, OUTPUT);
pinMode (D4pin, OUTPUT);
pinMode (D9pin, OUTPUT);//pwm
pinMode (D10pin, OUTPUT);//pwm
pinMode (D11pin, OUTPUT);//pwm
Serial.begin(115200);
}
void loop() {
Kecepatan = analogRead(potPin);
Kecepatan = map(Kecepatan, 0, 1023, 0, 255);
HallAState = digitalRead(HallApin);
HallBState = digitalRead(HallBpin);
HallCState = digitalRead(HallCpin);
if (HallAState == HIGH && HallBState == LOW && HallCState == HIGH) {
digitalWrite(D2pin, LOW);
digitalWrite(D3pin, HIGH);
digitalWrite(D4pin, LOW);
analogWrite(D9pin, Kecepatan);
digitalWrite(D10pin, LOW);
digitalWrite(D11pin, LOW);
}
else if (HallAState == HIGH && HallBState == LOW && HallCState == LOW) {
digitalWrite(D2pin, LOW);
digitalWrite(D3pin, LOW);
digitalWrite(D4pin, HIGH);
analogWrite(D9pin, Kecepatan);
digitalWrite(D10pin, LOW);
digitalWrite(D11pin, LOW);
}
else if (HallAState == HIGH && HallBState == HIGH && HallCState == LOW) {
digitalWrite(D2pin, LOW);
digitalWrite(D3pin, LOW);
digitalWrite(D4pin, HIGH);
digitalWrite(D9pin, LOW);
analogWrite(D10pin, Kecepatan);
digitalWrite(D11pin, LOW);
}
else if (HallAState == LOW && HallBState == HIGH && HallCState == LOW) {
digitalWrite(D2pin, HIGH);
digitalWrite(D3pin, LOW);
digitalWrite(D4pin, LOW);
digitalWrite(D9pin, LOW);
analogWrite(D10pin, Kecepatan);
digitalWrite(D11pin, LOW);
}
else if (HallAState == LOW && HallBState == HIGH && HallCState == HIGH) {
digitalWrite(D2pin, HIGH);
digitalWrite(D3pin, LOW);
digitalWrite(D4pin, LOW);
digitalWrite(D9pin, LOW);
digitalWrite(D10pin, LOW);
analogWrite(D11pin, Kecepatan);
}
else if (HallAState == LOW && HallBState == LOW && HallCState == HIGH) {
digitalWrite(D2pin, LOW);
digitalWrite(D3pin, HIGH);
digitalWrite(D4pin, LOW);
digitalWrite(D9pin, LOW);
digitalWrite(D10pin, LOW);
analogWrite(D11pin, Kecepatan);
}
};
note that "Kecepatan" is "Speed" i'm using that as a variable to my potentiometer. there's no error when i compiled it and uploaded it to my Arduino UNO. But i don't know why when i wired all of them into one piece my BLDC won't move. Also in reality my wiring is kind of different from the simulation in proteus, i'm using a 36V 10Ah Battery and i paralleled it to supply 1 Inverter IRF540N, 1 step down regulator 12V to supply driver IR2101, and 1 step down regulator 5V to supply BLDC Hall Sensor, Potentiometer and Arduino UNO. My step to turn it on is i added switch before inverter so when i connect my battery it will supply the 12V and 5V first and then i turn on the Inverter. After i've done all that, nothing happened, the arduino is on and i tried to give a little spin on potentiometer, nothing happened. Is there something i missed? thank you very much for the help.