So I got an RC motor connected to an ESC that is powered by an external battery pack, and controlled by an arduino using the Servo library.
The problem I am having is not making the motor spin, but having any sort of reasonable control over it.
It will only start at a high RPM, and it doesn't keep the same RPM even though I am writing more or less the same value to it using Servo.writeMicroseconds. I know that the motor and ESC works since when plugged into an RC reciever it works perfectly.
So I am not quite sure why this is happening and would like some help with finding out what the problem might be and what I can do to fix it.
Kind of a sidenote: Is there any decent servo shield I can use to fix this?
I am reading the input fron an RC controller and that seems to work fine, the values range from about 1000 to 2000.
Other than the source code I don't know what elso to say...
Since I don't have any good drawing software I might as well just write down my wiring.
from the RC recievers throttle channel I have it's signal connected to pin 8 on the arduino, ground to ground, and 5v from arduino to 5v on the reciever.
And from the arduino to the ESC I have pin 11 connected to signal, ground to ground, and the 5v cable on the esc is not connected to anything as it is 5v out.
Servo test code where you can send microsecond values from the serial monitor for testing.
// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.
String readString;
#include <Servo.h>
Servo myservo; // create servo object to control a 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-test-22-dual-input"); // so I can keep track of what is loaded
}
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
int n = readString.toInt(); //convert readString into a number
// auto select appropriate value, copied from someone elses code.
if(n >= 500)
{
Serial.print("writing Microseconds: ");
Serial.println(n);
myservo.writeMicroseconds(n);
}
else
{
Serial.print("writing Angle: ");
Serial.println(n);
myservo.write(n);
}
Serial.print("Last servo command position: ");
Serial.println(myservo.read());
readString=""; //empty for next input
}
}
Ok, so with the serial test code I can set it to a fixed RPM, however there is still no control to speak of. It only starts at a high RPM, and it seems as if it responds differently to the same entered value at different times.
Hi, a picture of the project will help, also a picture of a hand drawn circuit diagram is worth a thousand words.
What is your external battery pack and what is your RC motor?
How are you powering the arduino?
The thing is that the ESC does not work exactly the way a servo does. I does need a series of pulses to control it just like the servo does, but it also needs a pulse when arming.