I am trying to control a BLDC mottor with an esc and arduino.
My arduino board is UNO.
EMAX XA2212 1400KV bldc ( http://www.emaxmodel.com/views.asp?hw_id=1437 ).
ESC Hobbyking Skywalker 40A.
Gens Ace Li-Po 3S1P 3300mAh 11.1V 25C
I think my wiring is OK.
Problem is some of my code works, some doesn’t. Can’t figure out why!
Here is a code for speeding up the motor gradually, then stop for 1s and then loop.
But the problem is some times motor rotates clock-wise, sometimes anti-clock-wise! Why?
#include <Servo.h>
int PWMPin = 9;
Servo esc;
void setup(){
esc.attach(PWMPin, 700, 2000);
Serial.begin(9600);
}
void loop(){
for(int pulse = 700; pulse <= 1000; pulse += 100){
esc.writeMicroseconds(pulse);
delay(1000);
}
}
Here is a code for speeding up gradually in certain speed and then rotate constantly in that speed.
But sometimes it works, some time doesn’t! When it doesn’t work, bldc just do beep sounds in a constant interval. Can’t understand why?
#include <Servo.h>
int PWMPin = 9;
int pulse = 700;
Servo esc;
void setup(){
esc.attach(PWMPin, 700, 2000);
Serial.begin(9600);
}
void loop(){
for(; pulse <= 1000; pulse += 100){
esc.writeMicroseconds(pulse);
delay(1000);
}
}
Here is another code for rotating the motor in constant speed. But this time not gradually.
This works most of the times but not always. Sometimes it doesn’t work and motor just do beep sounds in constant interval.
#include <Servo.h>
int PWMPin = 9;
int pulse = 700;
Servo esc;
void setup(){
esc.attach(PWMPin, 700, 2000);
Serial.begin(9600);
}
void loop(){
if(pulse == 700){
esc.writeMicroseconds(pulse);
delay(1000);
pulse = 1000;
}
esc.writeMicroseconds(pulse);
}
Any nice documents / HOWTOs about understanding BLDC mottor controlling with arduino will be really appreciated.
Thanks!