I read all of the thread but can't find out how to control the brushless dc motor using ESC with arduino.
Here are are the elements that i want to use:
Arduino Deuemilanove
6 pole BLDC motor like the one shown on the link below: Brushless DC electric motor - Wikipedia
Please scroll down to see pic below the Application heading.
it has three wires coming out so its three phase i guess.
I took the ESC from a broken helicopter and i want to run my BLDC motor using this ESC. I can't find the instruction manual any useful because all of those tell you to configure ESC using the a remote transmitter module and its throttle stick.
If anyone have any idea as how can i achieve that objective using just an Arduino with ESC. I will be grateful.
You will talk to that ESC as if it were a servo. It expects the same signal as a servo does.
Are you using the motor out of the heli? Brushless motors come in all sizes, with different voltage and current demands. What load are you putting on the motor?
If the ESC does not have enough current capacity, you can quickly burn it out.
thanks for reply
I wrote a simple code like we do for servo. but there were two problems:
1). firstly the motor is just vibrating, its not revolving
2). Secondly, i want the motor to move at reasonably high speed i dont know how will we vary speed of the motor by using
myServoObject.write(int value)? as this command causes servos to move at same speed but to the specified acngle 0-180.
I didn't put any load on the motor and yes i am using it out of the heli. My ESC has 35A usual current and 45A burst current which is much larger than the motor need i think..
Your receiver in the heli has the same output for each channel. The throttle channel and the servos alike.
The servos use that signal to move to a certain position.
An ESC uses that signal to make the motor turn a certain speed.
So, writing 1000 to the servo object attached to the pin that the ESC is hooked to should equate to zero throttle, or a stopped motor. Writing 2000 should give full throttle. (not positive what those translate to on the 0-180 scale, something like 30-150 I think)
Note that some ESCs have to be armed by having a zero throttle command sent for a period of time, then a full throttle command, then a zero throttle command. You can easily determine your ESCs arming requirements by hooking it and the motor up to the receiver from the heli.
One thing i forgot to tell.. I also tried a battery eliminator circuit for powering 5v/Gnd to the ESC BEC (still providing servo signal from arduino) to check whether the current requirement of ESC is more then the arduino can supply but got same result. :-/
@vinceherman....do you know how can i reverse the direction of rotation of the motor while its connected with ESC and arduino as it was in above discussion?
Do you have the motor running now? If so, what was the fix?
Swapping any 2 of the 3 motor leads reverses a brushless motor. I have often thought of putting in an H-bridge to reverse a brushless motor, but have not tried that.
yah may motor is now running......earlier motor was not running as for arm-ment i was giving 15 microsecond delay between the low, full and low throttle. I gave 100 micro second delay it started working :). I guess since i have programmed ESC for soft start may be it was unable to pick full throttle in arm-ment process..
Initially your idea of arm-ment worked but then the motor stopped working again. I thought that either my ESC or motor got burnt. I bought new ESC Align BL35G ESC and 500T brushless DC motor.
First i programmed it using my arduino code that is posted below and then i programmed it using the standard transmitter/Receiver approach. In both cases the ESC got programmed well as indicated by the beeps it produce when in using mode but when i increase the throttle gradually from 1000 to 2000 the motor vibrates around 1140-1160 and then stops for the rest of the period.
Here is the code that i wrote for programming and running the Brushless DC motor while controllling ESC as a servo object from arduino.
Any help will be highly appreciated.
Thanks!
Code description:
1# -- Low throttle writes 1000uS = 1ms on servo pin i.e. generate pulse with 1ms on-time.
2# -- Mid throttle 1500 uS
3# -- Full Throttle 2000 uS
5# -- Run motor i.e. increase the pulse width from 1000uS to 2000uS.
You will also notice that in main while loop these commands are written every 10ms so in accordance to the servo objects rules that in order to keep running the motor at some speed we have to provide 1ms to 2ms pulse within every 20ms.
// Code starts here.
#include <Servo.h>
boolean CmdStatus = false;
Servo myServoObj;
int ServoPin = 3;
#define DelayBtwCmd 10
#define KeepMotorRunning 2000
#define DelayBtwMotorStartNconfigure 1000
#define ReceivedMsgLength 16
#define LineEnd '#'
char messageRecvd[ReceivedMsgLength];
char LstCmd = '\0';
int LowThrottle = 1000;
int MidThrottle = 1500;
int FullThrottle = 2000;
int TempMaxSpeed = MidThrottle;
void setup()
{
pinMode(ServoPin,OUTPUT);
myServoObj.attach(ServoPin);
Serial.begin(9600);
//Serial.println("Entered SetUp");
Serial.flush();
}
void loop()
{
// Serial.println("Entered Loop");
int inputLength = 0;
do
{
while (!Serial.available())
{
//myServoObj.write(LowThrottle);
if (LstCmd == '1')
{
myServoObj.writeMicroseconds(LowThrottle);
Serial.println("LOW Throttle");
delay(10);
}
else if(LstCmd == '2')
{
myServoObj.writeMicroseconds(MidThrottle);
Serial.println("MID Throttle");
delay(10);
}
else if(LstCmd == '3')
{
myServoObj.writeMicroseconds(FullThrottle);
Serial.println("FULL Throttle");
delay(10);
}
else if(LstCmd == '5')
{
myServoObj.writeMicroseconds(TempMaxSpeed);
Serial.println("TempMaxSpeed");
delay(10);
}
}; // wait for input
messageRecvd[inputLength] = Serial.read(); // read it in
} while (messageRecvd[inputLength] != LineEnd && ++inputLength < ReceivedMsgLength);
// Serial.println("Exited both while: Msg Read\n");
messageRecvd[inputLength] = 0; // add null terminator
Serial.print(messageRecvd);
LstCmd = messageRecvd[0];
HandleCommand(messageRecvd, inputLength);
}
void HandleCommand(char* input, int length)
{
if (length < 1)
{ return;}
int value = 0;
if (length > 1)
{ value = atoi(&input[1]); }
int* command = (int*)input;
switch(*command)
{
//SETUP MODE
case '1':
CmdStatus = false;
myServoObj.writeMicroseconds(LowThrottle);
//Serial.println(" -- Low Throttle Given");
delay(10);
break;
case '2':
CmdStatus = false;
myServoObj.writeMicroseconds(MidThrottle);
// Serial.println(" -- Mid Throttle Given");
delay(10);
break;
case '3':
CmdStatus = false;
myServoObj.writeMicroseconds(FullThrottle);
// Serial.println(" -- Full Throttle Given");
delay(10);
break;
//USING MODE
case '4': // Put throttle in LOW position
CmdStatus = false;
break;
case '5':
for(int ind = LowThrottle; ind < TempMaxSpeed; ind++)
{
myServoObj.writeMicroseconds(ind);
Serial.println(ind);
delay(10);
}
Serial.println(" -- END");
break;
case '6':
CmdStatus = true;
Serial.println("CMD stopped");
break;
default:
break;
}
}
Hi Xbee,
Can you go modify your post? Go highlight the code section and hit the # button on the toolbar. This puts your code into a code window that makes it easier to read. Good forum etiquette and all.
When I am working with ESCs on the Arduino, I like to use servos instead of the ESC and motors. This lets me see the servo move, from far one direction for zero throttle, to far in the other direction for full throttle. This keeps me from having to worry about spinning blades and blowing notes off my workspace.
Hook up a servo to your output pin instead of the ESC. Does it respond the way you expect the throttle commands to behave?
I do have to ask about the failure of the previous motor/ESC. Have you identified the cause of the failure? Have you tried connecting them directly to the RC receiver to confirm that they are broken? What kind of load are you placing on the motor during these experiments?