Pages: [1]   Go Down
Author Topic: Controlling a ESC with the servo library ?  (Read 1097 times)
0 Members and 1 Guest are viewing this topic.
Israel
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,

I have http://www.modelzone.co.uk/blc30c-brushless-motor-esc-combo-system.html ESC driver that is connected to a brushless motor.

And i have this simple servo:


I'm using the Sweep example:

Code:
#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
 
int pos = 0;    // variable to store the servo position
 
void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}
 
 
void loop()
{
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

This code works perfectly on the simple servo, but not on my ESC...
What modifications do i need to do to make it work ?

Thanks,
Dan
Logged

New Hampshire
Offline Offline
God Member
*****
Karma: 13
Posts: 779
There are 10 kinds of people, those who know binary, and those who don't.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Was the servo powered by the Arduino?

Is the ESC getting power from a separate battery?

I ask because if the external device (be it servo or ESC) is being powered by a separate battery, then the grounds from the Arduino and the battery need to be tied together.  Communications between the two will not work without a common ground.

Only the grounds though.  Do not tie the Positive lines together.
Logged


Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What modifications do i need to do to make it work ?

You need to find out the proper 'arming sequence' servo commands your ESC requires before it will actually control the motor, and place that command sequence into your start-up code in your sketch. This is a safety feature of most all ESCs so that it doesn't start up powering the motor when first turned on. On several of mine the sequence is command to 100% (2 millisec PPM signal) for 1 second, command to 0% for one second (1 millsec PPM signal), then ESC beeps and will except any motor command from 0% to 100%. Your ESC sequence may be different, so look for the proper information for your unit.


Lefty


Logged

Israel
Offline Offline
Newbie
*
Karma: 0
Posts: 38
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Was the servo powered by the Arduino?

Is the ESC getting power from a separate battery?

I ask because if the external device (be it servo or ESC) is being powered by a separate battery, then the grounds from the Arduino and the battery need to be tied together.  Communications between the two will not work without a common ground.

Only the grounds though.  Do not tie the Positive lines together.

Yup seperate battery, you were right! i tied up the grounds and it now works perfectly !

Quote
What modifications do i need to do to make it work ?

You need to find out the proper 'arming sequence' servo commands your ESC requires before it will actually control the motor, and place that command sequence into your start-up code in your sketch. This is a safety feature of most all ESCs so that it doesn't start up powering the motor when first turned on. On several of mine the sequence is command to 100% (2 millisec PPM signal) for 1 second, command to 0% for one second (1 millsec PPM signal), then ESC beeps and will except any motor command from 0% to 100%. Your ESC sequence may be different, so look for the proper information for your unit.


Lefty

I have something that i found out, i need to write '90' (center) each time before i tell him to start spining to diffrent side that he is currently spining, i have a continuous rotation servo smiley

How can i found out my 'arming-sequence'?
« Last Edit: September 28, 2011, 11:22:48 am by Danpe » Logged

0
Offline Offline
Shannon Member
****
Karma: 162
Posts: 10496
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Trial and error - a good guess is start at 0 (or a low value) and wait at least a second, then start ramping up slowly.

Since RC motors are extremely powerful the ESC has to have safety features to stop you accidentally slicing you fingers off with a propeller (yes, they are that powerful).  At the very least they will disarm themselves if started up with the throttle on and beep to warn that they are powered up and ready.
Logged

[ I won't respond to messages, use the forum please ]

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16548
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How can i found out my 'arming-sequence'?

It will be specific to the manufacturer and model ESC you have so look for it in the user manual, or data sheet or Internet searching, or failing that try and contact the supplier and ask for it.

Otherwise trial and error as MarkT suggested, however that is probably a last resort as it will be time consuming and frustration until you fall into the correct sequence and timing requirements, you may never figure it out. If you can't make the ESC beep it will never start up.

Lefty

« Last Edit: October 02, 2011, 06:54:24 pm by retrolefty » Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 101
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Worked for me (ebay Chinese ESC and motor):
ESC unpowered,
zero throttle,
power up the ESC,
wait for 2 seconds at 0 throttle (1 second required to arm the ESC), the ESC probably will beep with motor at powerup and at arming,
then, to be safe start at at least half the throttle. If you rise throttle too gradually the ESC may disarm for winding safety.

It's easiest to control the throttle with potentiometer and test different variations with that - no need to reprogram.
« Last Edit: October 02, 2011, 09:40:45 pm by kivig » Logged


Pages: [1]   Go Up
Jump to: