Go Down

Topic: ESC controll (Read 973 times) previous topic - next topic

May 31, 2012, 07:21 pm Last Edit: May 31, 2012, 07:24 pm by stunito0o0 Reason: 1
Hi guys,
I am from Bulgaria and just bought arduino adk.I want to controll an esc(brushed).I found a source for a servo and tested it on my esc and it works but my problem is  that  it starts, rotate a little then stops for a second or two and then rotate a little again. I want to change it so i can select speed and rotate it without breaks ,but dont uderstand the source enough to do it.So my  request is to explain it to me please.My ESC is sp-03018. Here is the source:

int servoPin = 2;
int myAngle;
int pulseWidth;
void setup ()
{
pinMode (servoPin, OUTPUT);
}
void servoPulse (int servoPin, int myAngle)
{
pulseWidth = (myAngle* 10) + 600;
digitalWrite (servoPin, HIGH);
delayMicroseconds (pulseWidth);
digitalWrite (servoPin, LOW);
}
void loop ()
{
for(myAngle = 10;myAngle <= 170; myAngle++)
{
servoPulse (servoPin, myAngle);
delay (20);
}
for (myAngle = 170; myAngle>= 10;myAngle--)
{
servoPulse (servoPin, myAngle);
delay (20);
}
}
PS.I am sorry for my bad english. :)

dxw00d

Why are you not using the servo library? It is supplied with the IDE. There are a couple of example sketches too.

http://arduino.cc/en/Reference/Servo

#2
May 31, 2012, 07:58 pm Last Edit: May 31, 2012, 08:01 pm by stunito0o0 Reason: 1
Because I heard that this libraly can controll only 2 at once, am planning to controll 4 escs :)  
EDIT:I saw now that it can controll up to 12 thx i'll try it.

MichaelMeissner

It may be earlier versions only supported 2 servos, but from what I've read, an Arduino would have trouble controlling more than 2 servos if the Arduino has to power the servo (it may even have problems powering one servo depending on what else you are using).  If you are going to power 4 servos, I would expect you would need the servos on a separate power circuit -- you need to wire the ground of the two power supplies together.

DuaneB

Have a look around my blog, lots of information on servos and escs with Arduino -

rcarduino.blogspot.com

Duane B
Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

Hi
This may help you

Code: [Select]

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
               
void setup()
{
  //Serial.begin(9600);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}


void loop()
{

/*
Forward Direction:
   starts jittering : 1586 s pulse
   smooth movement: 1610 s pulse
   full forward: 2120 s pulse
Reverse Direction:
   starts jittering: 1428 s pulse
   smooth movement: 1422 s pulse
   full: 875 s pulse
*/
//
myservo.writeMicroseconds(1586);
//Serial.println("starts jittering");
delay(10000);

myservo.writeMicroseconds(1610);
//Serial.println("Smooth Fwd");
delay(10000);

myservo.writeMicroseconds(2120);
//Serial.println("full forward");
delay(10000);

myservo.writeMicroseconds(1428);
//Serial.println("starts jittering");
delay(10000);

myservo.writeMicroseconds(1422);
//Serial.println(" smooth movement ");
delay(10000);

myservo.writeMicroseconds(875);
//Serial.println("Full reverse ");
delay(10000);

myservo.writeMicroseconds(1428);
//Serial.println("starts jittering");
delay(10000);


}



I got the pulses time from this document at the following link

http://mvdhoef.wesg.ca/PDF/SDD.pdf

Please tell me if you got something new since I am also working on a project using the same ESC "SP-03018"


DuaneB

If your using RC Transmitters, why not just capture the real values and calibrate based on them -

Some background and examples here -

http://rcarduino.blogspot.com/2012/05/interfacing-rc-channels-to-l293d-motor.html

Values are captured in a program mode and then stored in EEPROM for use now and in the future.

Duane B
Read this
http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html
then watch this
http://rcarduino.blogspot.com/2012/04/servo-problems-part-2-demonstration.html

Rcarduino.blogspot.com

Go Up