DatTruong/Howard/code2

Re: Controlling A Brushless Motor Reply #9 - 27.11.2008 at 11:46:55 The ESC needs to arm before it will drive the motor. Typically an ESC will arm when it gets minimum throttle setting for a second or so. But some controllers are programmable or self adapt to the transmitter so you need to read the instructions for your ESC.

Lazer’s code arms his ESC because it starts by sending a minimum pulse width for 1 second.

I would recommend that code to drive an ESC had a specific function for arming. Here is an example, this may need to be modified for ESC that need longer arm times or different pulse widths. And its not tested so let me know if it works for you Wink

Code:

// this uses the Arduino servo library included with version 0012

// caution, this code sweeps the motor up to maximum speed ! // make sure the motor is mounted securily before running.


 * 1) include 

Servo myservo;

void arm{ // arm the speed controller, modify as necessary for your ESC setSpeed(0); delay(1000); //delay 1 second, some speed controllers may need longer }

void setSpeed(int speed){ // speed is from 0 to 100 where 0 is off and 100 is maximum speed //the following maps speed values of 0-100 to angles from 0-180, // some speed controllers may need different values, see the ESC instructions int angle = map(speed, 0, 100, 0, 180); myservo.write(angle); }

void setup { myservo.attach(9); arm; }

void loop { int speed;

// sweep up from 0 to to maximum speed in 20 seconds for(speed = 0; speed <= 100; speed += 5) { setSpeed(speed); delay(1000); } // sweep back down to 0 speed. for(speed = 95; speed > 0; speed -= 5) { setSpeed(speed); delay(1000); } setSpeed(0); delay(5000); // stop the motor for 5 seconds }