Pages: [1]   Go Down
Author Topic: ESC controll  (Read 840 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley
« Last Edit: May 31, 2012, 12:24:39 pm by stunito0o0 » Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Because I heard that this libraly can controll only 2 at once, am planning to controll 4 escs smiley  
EDIT:I saw now that it can controll up to 12 thx i'll try it.
« Last Edit: May 31, 2012, 01:01:43 pm by stunito0o0 » Logged

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 53
Posts: 1832
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

rcarduino.blogspot.com

Duane B
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi
This may help you

Code:
#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"

Logged

Dubai, UAE
Offline Offline
Edison Member
*
Karma: 22
Posts: 1675
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Pages: [1]   Go Up
Jump to: