RC ESC controlling

Hi!

I made the connection with the ESC, but when i want to write a position to a motor that doesnt do anything.
Code:

#include <Servo.h>
int escPin = 9;
Servo motor;
void setup() 
  {
    motor.attach(escPin);
  }
void loop()
{
  motor.write(90);
}

Does the ESC have an arming sequence?

When i connect the arduino, the ESC is armed immediately.

PyroxHu:
When i connect the arduino, the ESC is armed immediately.

That would be unusual. How do you know?

What exactly do you mean by "connect the Arduino"?

I presume the ESC and the motor it controls have their own power supply.

...R

PyroxHu:
When i connect the arduino, the ESC is armed immediately.

But the symptom you give is likely because the ESC is not armed. I don't see anything in your code that looks like an arming sequence. Do you understand why ESCs needed a arming sequence and how it is performed on your specific ESC? Perhaps a link to your ESC would help shed light on the subject.

Recent discussion that might have useful info.

http://forum.arduino.cc/index.php?topic=226594.0

Writing 90 degrees is equivalent to telling the motor not to move...

If you try writing something else in your loop, the ESC will probably go into either an error or a calibration mode. As others have said, you need to let it arm. This requires a constant neutral signal for half a second or so (maybe a bit more depending on your ESC). What is defined as neutral depends on how the ESC has been calibrated, but is probably close to a 1500 microsecond pulse. Try adding writeMicroseconds(1500) and a delay in the setup routine. Then write whatever you like later.

If this doesn't work, make sure that the ESC is calibrated correctly. It needs to know the max, minimum, and neutral signals. The manual will tell you how to do this.

Stingray:
Writing 90 degrees is equivalent to telling the motor not to move...

I think that is only true if the ESC supports forward and reverse. I presume if it only supports one direction that 90 signifies half speed. We have not been told what ESC the OP is using.

...R

Robin2:

Stingray:
Writing 90 degrees is equivalent to telling the motor not to move...

I think that is only true if the ESC supports forward and reverse. I presume if it only supports one direction that 90 signifies half speed. We have not been told what ESC the OP is using.

I think that 90 degrees corresponds to 1500 us. That would correspond to neutral position for the trigger on any standard radio, and should also be neutral for the ESC. Shorter pulses on a forward-only ESC correspond to braking.

Stingray:

Robin2:

Stingray:
I think that 90 degrees corresponds to 1500 us. That would correspond to neutral position for the trigger on any standard radio, and should also be neutral for the ESC. Shorter pulses on a forward-only ESC correspond to braking.

I was thinking of a model aircraft ESC which wouldn't have braking, so I guess either of us may be right.

...R

The original poster needs to supply info on the ESC he/she has. Below is some servo test code. I suggest the esc be sent 35 deg (~1000us) control value and see if the esc respond. If so, then send 135 deg. (~2000us) and see if the motor speed up.

// zoomkat 12-25-13 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// Send an a to attach servo or d to detach servo
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include <Servo.h> 
String readString; //String captured from serial port
Servo myservo;  // create servo object to control a servo 
int n; //value to write to servo

void setup() {
  Serial.begin(9600);
  myservo.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7, 500, 2500);  //the pin for the servo control, and range if desired
  Serial.println("servo all-in-one test code 12-25-13"); // so I can keep track of what is loaded
  Serial.println();
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 

      // attach or detach servo if desired
    if (readString == "d") { 
      myservo.detach(); //detach servo
      Serial.println("servo detached");
      goto bailout; //jump over writing to servo
    }
    if (readString == "a") {
      myservo.attach(7); //reattach servo to pin 7
      Serial.println("servo attached");
      goto bailout;
    }    

    n = readString.toInt();  //convert readString into a number

    // auto select appropriate value
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n); 
    }

bailout: //reenter code loop
    Serial.print("Last servo command position: ");    
    Serial.println(myservo.read());
    Serial.println();
    readString=""; //empty for next input
  }
}