I have a Turnigy Plush 18 amp speed controller connected to a brusheless motor, how do I program my arduino uno so that it controls the motor?
I wonder what Google would say.
I think that I have to connect it to an arduino output not input.......
Did anyone suggest otherwise? :o
there are only analog inputs not ouputs
there are only analog inputs not ouputs
But there are PWM outputs that can generate an analogue voltage if you put a filter on them.
But as Richard said it is nothing to do with a servo control.
You probably need to do a forum search for "ESC" to see previous discussions concerning the brushless motor controllers. There is an arming sequence that is usually required. Below is some servo test code that may be of use.
// zoomkat 10-4-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// for IDE 0019 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.attach(7); //the pin for the servo control
Serial.println("servo-test-21"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
delay(10);
if (Serial.available() >0) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
}
}
if (readString.length() >0) {
Serial.println(readString); //so you can see the captured string
int n;
char carray[6]; //converting string to number
readString.toCharArray(carray, sizeof(carray));
n = atoi(carray);
myservo.writeMicroseconds(n); // for microseconds
//myservo.write(n); //for degees 0-180
readString="";
}
}
Hi, I have used the following code to control a brushless motor through an ESC, but all I get is successfully arm the esc and make the motor move for a while. Then the motor speeds down to a complete stop:
// Import the Arduino Servo library
#include
#define FRONTMOTORPIN 3
void setup()
{
pinMode(FRONTMOTORPIN, OUTPUT);
//arm esc
analogWrite(FRONTMOTORPIN, 124);
delay(2000);
// Open the serial connection, 9600 baud
Serial.begin(9600);
}
void loop()
{
analogWrite(FRONTMOTORPIN, 1000);
delay(10);
}
My h/w setup is:
Arduino duemilanove
Turnigy Plush 18A ESC
Turnigy 2217 16turn 1050kv 23A Outrunner motor
The esc is powered by external source, the arduino by usb and the signal cable from the esc is connected to arduino pin 3 and the ground cable to the ground pin of arduino.
Any ideas why this happens? Thanks
Thanks for the info, I have found this page very useful: Arduino Playground - Servo and especially the part where it states "Extra Methods: refresh()
You must call this at least once every 50ms to keep the servos updated. You can call it as often as you like, it won't fire more than once every 20ms. When it does fire, it will take from .5 to 2.5 milliseconds to complete, but won't disable interrupts."
It looks like in the main loop I should add something like "SoftwareServo::refresh();"
I will try it and keep you updated with the results
It looks like in the main loop I should add something like "SoftwareServo::refresh();"
In the sketch that you posted, you are not using SoftwareServo, so calling a method of that class won't work.
The Servo library already calls refresh on a regular basis.
Hi PaulS, Thanks for your remark. Actually, I have no intension to use the method in my code, but create new code using the SoftwareServo library.
Can anybody explain the behavior of the motor with the posted sketch? (it runs for abt 10 seconds and then slows down to a stop). It must be something with the pulse and the update (10ms) probably a small refresh value for the servo??
You go first. Explain what is happening here.
analogWrite(FRONTMOTORPIN, 1000);
Reference the documentation for analogWrite, if you need to. Hint - you do need to.
Especially the bit about the valid of values input to the function.
Can anybody explain the behavior of the motor with the posted sketch? (it runs for abt 10 seconds and then slows down to a stop). It must be something with the pulse and the update (10ms) probably a small refresh value for the servo??
Probably because you keep trying to use PWM instead of the servo PPM.
Thank you all for your replies. Here is my current situation. I have created a small sketch using the servo library:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
String readString;
void setup()
{
myservo.attach(6);
Serial.begin(9600);
}
void Arm() {
myservo.write(10);
delay(2000);
Serial.println("Armed!");
}
void loop()
{
while (Serial.available()) {
delay(10);
if (Serial.available() >0) {
char c = Serial.read(); //gets one byte from serial buffer
readString += c; //makes the string readString
}
}
if (readString.length() >0) {
Serial.println(readString); //so you can see the captured string
if(readString=="A") {
Arm();
readString="";
}
else {
int n;
char carray[4]; //converting string to number
readString.toCharArray(carray, sizeof(carray));
n = atoi(carray);
readString="";
Serial.println("Number: ");
Serial.println(n);
myservo.write(n);
}
}
delay(10);
}
This code makes the motor behave still in a strange manner: When I send 'A' the ESC arms the motor and makes the appropriate beeps. Then it starts beeping in a sequence, that according to the ESC manual it means that there is an input error (or no pulse input). I send a value (e.g., 100) and then motor starts to spin at a variable speed and after a few seconds it stops.
If I want to send another value and make the motor move again, I have to either send an arm command ('A') or a low speed value, e.g. 10.
What shall I do to make it spin at a stable speed?
Thanks.