How to "talk to" the ESC of a brushless motor

Hello,

From a, now defunct, RC airplane, I have removed the power system.

I want to connect the ESC to the Arduino instead of the airplane's receiver. This is done via the 3-pin cable, same that servo's have.

I read somewhere that ESC's can be treated as servos. So can I use servo.write(0-179) upon the ESC's white cable ?

What about the red and black cables ? An ESC is powered from the main battery, so can I ignore the red and black ? (ie not connect anything to them)

Thanks in advance, Dimitris

Some ESC reading material.

https://www.google.com/search?as_q=esc&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fforum.arduino.cc%2Findex&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=&gws_rd=ssl

The ESC has an arming sequence which must be implemented in your Arduino sketch. If you ever flew the plane then you probably know that the throttle has to be set to zero for a few seconds before it will arm.

ESC power is from your battery, the signal wire connects to the Arduino, and one wire must be connected between the ESC's battery GND and the Arduino GND if you're using two power sources. A USB connection between your computer and the Arduino is a second power source. Assuming the ESC has a BEC then you can use the red and black wires to power the Arduino (connect to 5V and GND) when disconnected from your computer's USB.

http://rcarduino.blogspot.com/ has lots of information you can dig through.

dtrip: I read somewhere that ESC's can be treated as servos. So can I use servo.write(0-179) upon the ESC's white cable ?

Yes, you have to...

What about the red and black cables ? An ESC is powered from the main battery, so can I ignore the red and black ? (ie not connect anything to them)

No, black is ground and you must connect grounds in common (otherwise you don't have a circuit). Red will be the BEC output if the ESC has a BEC. Don't connect unless you want to power the Arduino from the BEC, in which case check that its 5V and connect to 5V pin. I don't trust ESCs since one exploded on first power up, so I wouldn't normally trust the 5V from it to power anything valuable.

Hello, thanks

I have hardwired

Chagrin: The ESC has an arming sequence which must be implemented in your Arduino sketch. If you ever flew the plane then you probably know that the throttle has to be set to zero for a few seconds before it will arm.

Yes, arming is for safety purposes (for example, turning an airplane on with the throttle stick up, might result in the airplane going wild). So the system requires first to go to "throttle zero" for a few seconds, then it beeps to indicate that it is "armed", meaning that it now responds to stick movements.

Thank you for verification, I have tried connecting a joystick to control the ESC and seems to work, but the ESC will not arm. From the beeps Im hearing, it seems to go into programming mode. It seems to acknowledge "max throttle" because as far as I remember this is what is used to "select" (it does go into "submenus", because the total number of beeps is different each time). But it does not seem to acknowledge "min throttle", which I have assumed is zero.

I have even hardwired

motor.write(0); delay(1000);

into the loop(),

but it will still not arm.

Isnt zero the "min throttle" required to arm ?

EDIT: It seems the sequence is different for each ESC, however I would like some confirmation about min and max values, for example write(0) is "throttle stick fully down" and write(179) is "throttle stick fully up" ?

Hello! I would suggest that you try to arm it with the reversed settings. Some ESC:s have the inouts reversed and i think this might be your problem. Try a start with 179 instead and that should work. Many ESC:s go into programming mode when started at full trottle.

Thanks, I have tried that. I have tried a multitude of combination of starting low --> then high, and the opposite. For various seconds each time. None worked. When I give it a write(0) it gives a beep every second, which means "throttle signal is invalid". ie it seems it does not recognize the write(0) as the lowest throttle value. It does recognize the 179 as the highest, or the 160, etc.

Ive seen some programs that use a for() instruction to go from 160 to 0, ie they dont "jump" suddenly from high to low values.

I will try that tomorrow and also a new pair of ESC/motor that I have hanging around.

Oh, the ESC is a Turnigy, Ive read somewhere that they are "nasty" in programming with Arduino, is that correct ? Which brand is the "easiest", does anyone know ?

EDIT: It seems the sequence is different for each ESC, however I would like some confirmation about min and max values, for example write(0) is "throttle stick fully down" and write(179) is "throttle stick fully up" ?

RC tx/rx setups probably only use servo commands for +=45 deg of servo rotation. So a 45 deg command might be equal to 0 throttle and 135 deg command might equal full throttle.

As I understand it, the default PWM signal for a servo corresponds to 90 degrees, so try sending that.

As I understand it, the purpose of the red and black cable is not usually to provide power to the ESC, it is so the ESC can provide power to a radio receiver.

Mate, here is a simple sketch to get you started.

Place a poti on your breadboard, connect plus and minus accordingly, wire it up to your Analog 1.

Connect the ESC to a breadboard, run a wire from the yellow cable of the connector to a PWM port of the Arduino (9, in my example).

Upload this code in the Arduino. After that, connect the battery to the ESC (motor already wired to the ESC).

The motors should beep - First beep sequence shows the number of cells in the LiPo attached, second beeps show the “armed” status.

#include <Servo.h>
 
Servo esc;
int throttlePin = 1;
 
void setup()
{
esc.attach(9, 1000, 2000);
Serial.begin(9600);
}
 
void loop()
{
int throttle = analogRead(throttlePin);
throttle = map(throttle, 0, 1023, 0, 179);
esc.write(throttle);
Serial.println(throttle);
}

dtrip: Thanks, I have tried that.

Oh, the ESC is a Turnigy, Ive read somewhere that they are "nasty" in programming with Arduino, is that correct ? Which brand is the "easiest", does anyone know ?

they are not too clever with RC either. Which do you have ? Some need a "dongle" to programme.